//ページ読み込み時

window.onload=function(){



/* URLによってクッキー書き込み */
var param = location.href.match(/a=\d\d&s=\d/ig);

if(param){
	var ck='?'+param;
	createCookie('wp_time',ck);
}

/* クッキー読み出し */

var ckParam = readCookie('wp_time');	

/* クッキーがあったとき */
	if(ckParam){
		var links = document.links; 
		for(i=0;i<links.length;i++){


/* リンクによる分岐 */
			if(links[i].target){
				if(links[i].href.match(/^http:\/\/www2.nhk-g.co.jp\/wp\//ig)){
					if((links[i].href.match(/a=\d\d&s=\d/ig))||(links[i].href.indexOf("p_Info",0)>=0)){
					}else{
							if(links[i].href.indexOf(".html",0)>=0){
									var urlControl = new Array();											
									urlControl=links[i].href.split(".html");
									links[i].href = urlControl[0]+".html"+ckParam+urlControl[1];
							}
							if(links[i].href.indexOf(".asp",0)>=0){
									var urlControl = new Array();
									urlControl=links[i].href.split(".asp");
									links[i].href = urlControl[0]+".asp"+ckParam+urlControl[1];
							}
					}
				}
			}
			else{
					if((links[i].href.match(/a=\d\d&s=\d/ig))||(links[i].href.indexOf("p_Info",0)>=0)){
					}else{
							if(links[i].href.indexOf(".html",0)>=0){
									var urlControl = new Array();
									urlControl=links[i].href.split(".html");
									links[i].href = urlControl[0]+".html"+ckParam+urlControl[1];
									
							}										
							if(links[i].href.indexOf(".asp",0)>=0){
									var urlControl = new Array();
									urlControl=links[i].href.split(".asp");
									links[i].href = urlControl[0]+".asp"+ckParam+urlControl[1];
							}
					}
			}
		}
	}
	
/* hotel用 */
		if((location.href.indexOf("hotel/index",0)>=0)||(location.href.match(/hotel\/$/ig))){
			hotelInit('countrySelect');
		}

/* apply用 */
		if((location.href.indexOf("apply/index.",0)>=0)||(location.href.indexOf("apply/index_e.",0)>=0)||(location.href.match(/apply\/$/ig))){
			applyInit('countrySelect');
		}


/* inquiry用 */
if(location.href.indexOf("inquiry/02",0)!=-1){
			Element.hide('suspensionDiv');
			Element.hide('resumptionDiv');
			Element.hide('cancellationDiv1');
			Element.hide('cancellationDiv2');
			Element.hide('irdDiv');
			Element.hide('ird_y');	
			Element.hide('ird_n');
}

if(location.href.indexOf("inquiry/03",0)!=-1){
			Element.hide('cardDiv');
			Element.hide('wireDiv');

			document.getElementById('billing_address').setAttribute('disabled', 'disabled');

			var isMSIE = /*@cc_on!@*/false;
			if (isMSIE) { 
						document.inqForm.billing_send[0].setAttribute("onclick", new Function("setTFoff();"));
						document.inqForm.billing_send[1].setAttribute("onclick", new Function("setTF();"));
			} else {
						document.inqForm.billing_send[0].setAttribute('onclick', 'javascript:setTFoff();');
						document.inqForm.billing_send[1].setAttribute('onclick', 'javascript:setTF();');
			}			
}

if(location.href.indexOf("inquiry/04",0)!=-1){
			Element.hide('cardDiv');
			Element.hide('wireDiv');
			document.getElementById('billing_address').setAttribute('disabled', 'disabled');

			var isMSIE = /*@cc_on!@*/false;
			if (isMSIE) { 
						document.inqForm.billing_send[0].setAttribute("onclick", new Function("setTFoff();"));
						document.inqForm.billing_send[1].setAttribute("onclick", new Function("setTF();"));
			} else {
						document.inqForm.billing_send[0].setAttribute('onclick', 'javascript:setTFoff();');
						document.inqForm.billing_send[1].setAttribute('onclick', 'javascript:setTF();');
			}			

		}

}


/* =============================================クッキー用関数========= */
		
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}