$(document).ready(function() {
$("#isExisting").hide();
$(".ac5").hide();
$(".ac6").hide();
$(".ac7").hide();
$(".ac8").hide();
$(".ac9").hide();
$(".ac10").hide();
$(".errorMsg").hide();

//$(":checkbox").attr("checked", "");
//$(":radio").attr("checked", "");

var i=5;

$("input[@name='existingCustomer']").click(
function()
{
if ($("input[@value='Y']:checked").val())
$("#isExisting").slideDown("fast");
else if ($("input[@value='N']:checked").val())
$("#isExisting").slideUp("fast");
}
);

//$(":checkbox[@name='option1[]']").click(checkboxValidate);

$(":checkbox[@name='option1[]'][@value='others']").click(
function()
{
if($(":checkbox[@name='option1[]'][@value='others']").is(":checked")){
$("input[@name='othersDetail']").attr("disabled", "");
}else{
$("input[@name='othersDetail']").attr("disabled", "disabled");
}
}
);

function checkboxValidate() {
 //var n = $("input:checked").length;
//$("div").text(n + (n == 1 ? " is" : " are") + " checked!");
var abc = $(":checkbox[@name='option1']:checked").length;
if (abc<1){
	$(".errorNoneChecked").show();
	//$("tr:has(:checkbox[@name='option1'])").addClass("formError");
}else if (abc>0){
	//$("tr:has(:checkbox[@name='option1'])").removeClass("formError");
	$(".errorNoneChecked").hide();
	}
}


$("#add").click(function(event){
   event.preventDefault();
   if(i<=10){
   $(".ac"+i).show();
   i++;
   }
   if(i>10){
	   $("#add").hide();
	   }
});

$(".whatisit").hide();
$("#whatisit").hover(function(event){
   event.preventDefault();
   $(".whatisit").show();
}, function(event){
	event.preventDefault();
   $(".whatisit").hide();
});

$("input[@name='contactTime']").click(
function()
{
if ($("input[@value='day']:checked").val()){
	$("input[@name='daytime']").removeAttr("disabled");
	$("input[@name='daytime']").val("");
	
	$("input[@name='eveningtime']").attr("disabled", "disabled");
	$("input[@name='eveningtime']").val("N/A");	
}
else if ($("input[@value='evening']:checked").val()){
	$("input[@name='eveningtime']").removeAttr("disabled");
	$("input[@name='eveningtime']").val("");
	
	$("input[@name='daytime']").attr("disabled", "disabled");
	$("input[@name='daytime']").val("N/A");	
}
}
);

$(".historicalStockPrice tr:even").addClass("historicalStockPriceDataBgcolor");
$(".historicalStockPrice tr:even td").addClass("historicalStockPriceDataBgcolor");
$(".historicalStockPrice tr:odd").addClass("historicalStockPriceDataNoBgcolor");
$(".historicalStockPrice tr:odd td").addClass("historicalStockPriceDataNoBgcolor");
$(".historicalStockPrice tr:first ").removeClass("historicalStockPriceDataBgcolor");
$(".historicalStockPrice tr:first ").addClass("historicalStockPriceDataTitleTr");
$(".historicalStockPrice tr:first td ").removeClass("historicalStockPriceDataBgcolor");
$(".historicalStockPrice tr:first td ").addClass("historicalStockPriceDataTitleTd");


$(function () {
  $('.submitBtn').hover(function () {
    this.src = '/resources/Common/images/btn_submit_over.gif';
  }, function () {
    this.src = '/resources/Common/images/btn_submit_off.gif';
  });
});

$(function () {
  $('.clearBtn').hover(function () {
    this.src = '/resources/Common/images/btn_clear_over.gif';
  }, function () {
    this.src = '/resources/Common/images/btn_clear_off.gif';
  });
});

$(function () {
  $('.clearBtn').click(function () {
    this.src = '/resources/Common/images/btn_clear_off.gif';
  });
});

$(function () {
  $('.subscribeBtn').hover(function () {
    this.src = '/resources/Common/images/btn_subscribe_over.gif';
  }, function () {
    this.src = '/resources/Common/images/btn_subscribe_off.gif';
  });
});

$(function () {
  $('.unsubscribeBtn').hover(function () {
    this.src = '/resources/Common/images/btn_unsubscribe_over.gif';
  }, function () {
    this.src = '/resources/Common/images/btn_unsubscribe_off.gif';
  });
});

$(function () {
  $('.showdataBtn').hover(function () {
    this.src = '/resources/Common/images/btn_showdata_over.gif';
  }, function () {
    this.src = '/resources/Common/images/btn_showdata_off.gif';
  });
});

$(function () {
  $('.addAccBtn').hover(function () {
    this.src = '/resources/Common/images/btn2_add_over.gif';
  }, function () {
    this.src = '/resources/Common/images/btn2_add_off.gif';
  });
});

$(function () {
  $('.addAccBtn').click(function () {
    this.src = '/resources/Common/images/btn2_add_off.gif';
  });
});

$(function () {
  $('.searchBtn').hover(function () {
    this.src = '/resources/Common/images/btn_search_over.gif';
  }, function () {
    this.src = '/resources/Common/images/btn_search_off.gif';
  });
});

$(function () {
  $('.testBtn').hover(function () {
    this.src = '/resources/Common/images/btn_test_over.gif';
  }, function () {
    this.src = '/resources/Common/images/btn_test_off.gif';
  });
});

if (isIE()) {
  try {
    document.getElementById("oPersistInput").addBehavior("#default#userdata");
	}catch (ex){}
}

});

function isIE()
{
  return !!document.all;
}

function popup() {
	var url = "/resources/Terms%20of%20Use/privacy_information_collection_statement.htm";
	window.open(url,'newwindow','height=500,width=540,top=0,left=250,toolbar=no,menubar=no,resizable=yes,location=no,status=no,scrollbars=yes');
}

function popupURL(url) {
	var thisUrl = "/staticfiles/PCCWCorpsite/Terms of Use/privacy_information_collection_statement.htm";
	window.open(thisUrl,'newwindow','height=500,width=540,top=0,left=250,toolbar=no,menubar=no,resizable=yes,location=no,status=no,scrollbars=yes');
}

function fnSaveInput(key, value){
  var ex;
  if(isIE()){  //IE
    try {  
      var oPersist = document.getElementById("oPersistInput");
      oPersist.setAttribute("sPersist",value);
      oPersist.expires = new Date(0).toUTCString();
      oPersist.save(key);
    }catch (ex){}
  } else if(window.sessionStorage){  //FF 2.0+
    try{
      sessionStorage.setItem(key,value)
    }catch (ex){}
  } else{
    alert("Error occured in user data saving. your browser do not support user data.");
  }
}

function fnLoadInput(key){
  var ex;
  var temp;
  if(isIE()){  //IE
    try {
      var oPersist = document.getElementById("oPersistInput");
      oPersist.load(key);
      return oPersist.getAttribute("sPersist");
    } catch (ex){}
  }else if(window.sessionStorage){   //FF 2.0+
    try{
      return sessionStorage.getItem(key)
    } catch (ex){} 
  }else{
    alert("Error occured in user data loading. your browser do not support user data.")
  }
}

function fnDeleteInput(key){
  var ex;
  if(isIE()){  //IE
    try {
      var oPersist = document.getElementById("oPersistInput");
      oPersist.load(key);
      oPersist.expires = new Date(315532799000).toUTCString();
      oPersist.save(key);
    } catch (ex){}
  }else if(window.sessionStorage){  //FF 2.0+
    try{
      sessionStorage.removeItem(key)
    } catch (ex){}
  }else{
    alert("Error occured in user data deleting. your browser do not support user data.")
  }
}

