var newwin_chat;

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
	if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
	obj.visibility=v; }
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function dounique() { 
	var date = new Date() ; return date.getTime() ; 
}

function closeAnnoucement() {
	document.getElementById("downAnnouncement").style.display="none";
	if(getCookie('downtimeAnnouncement') == ""){
		setCookie('downtimeAnnouncement','read',1);
	} 
}

function callSupport(strUser, strEmail, strSubject, strMessage, strdeptid, strcsite) {
		//var sURL= "http://support.ibcjapan.co.jp/setcookie_csite.php?user=" + strUser + "&email=" + strEmail + "&subject=" + strSubject + "&message=" + strMessage + "&deptid=" + strdeptid + "&csite=" + strcsite;
    	//var newwin = '';
		//var unique = dounique();
		//newwin = window.open(sURL, unique, 'scrollbars=no,menubar=no,resizable=0,location=no,screenX=50,screenY=100,width=450,height=350' );
		//newwin.focus();
	//var sURL="http://support.ibcjapan.co.jp/setcookie_csite.php?user=" + strUser + "&email=" + strEmail + "&subject=" + strSubject + "&message=" + strMessage + "&deptid=" + strdeptid + "&csite=" + strcsite;
//	var sURL= "http://chat.ibcjapan.co.jp:8080/IBCChat/?siteID=7";
	
	//var sURL= "http://chat.autoterminal.com:8080/Chat/?siteID=7";
	var sURL = "http://chat.autoterminal.com:8080/Chat/?siteid=7";
	
	if (!newwin_chat || newwin_chat.closed) {
		newwin_chat = window.open(sURL,'mywindow', 'scrollbars=no,menubar=no,resizable=0,location=no,screenX=50,screenY=100,width=450,height=405' );
		if(newwin_chat) newwin_chat.focus();
	}
	else{
		if(newwin_chat) newwin_chat.focus();
	}	
}

// Hide e-mail from robots
function UsrAtDmn(usr,dmn,className){
	at="@"
	document.write("<a href=\"mailto:" + usr + at + dmn + "\" class=\"" + className + "\">" + usr + at + dmn + "</a>")
}

/*Skype Tracking*/
function Skype_Track(site, region, cid){
	 AjaxCon = new AjaxDell();
	 if(!AjaxCon) return;
	 var strParams = "site=" + site + "&region=" + region + "&cid=" + cid;
	 fn_Skype_Track = function(xmlObj){/*alert(strParams )*/}
	 AjaxCon.connect("/skype_track.asp", "GET", strParams , fn_Skype_Track);
	}

function checkCountry(valEntry){
	var boolError;
	var strRedirect;
	var strATAFCountry = 'AlgeriaAngolaBeninBotswanaBurundiCameroonCongo BrazzavilleD. R. Of CongoDjiboutiEthiopiaGambiaGhanaIvory CoastKenyaLesothoLibyaMalawiMauritaniaMauritiusMozambiqueNamibiaNigeriaRwandaSenegalSeychellesSierra LeoneSouth AfricaSudanSwazilandTanzaniaTogoTunisiaUgandaZambiaZimbabwe';
	var strATOZCountry = 'Australia'
	boolError = true;
	
	if (strATAFCountry.indexOf(valEntry) != -1 && valEntry !='') {
		boolError = false;
		//kindly change the strRedirect when your testing in your local
		//strRedirect = '/ataf/application_form.asp';
		strRedirect = 'http://africa.autoterminal.com/application_form.asp', '_self';
	}
	if (strATOZCountry.indexOf(valEntry) != -1 && valEntry !='') {
		boolError = false;
		//kindly change the strRedirect when your testing in your local
		//strRedirect = '/atoz/application_form.asp';
		strRedirect = 'http://australia.autoterminal.com/application_form.asp', '_self';
	}
	if (! boolError) {
		if(confirm("Choosing this country will redirect you to it's respective region. \n Do you want to continue?")){
			window.location.href = strRedirect;
		} else {
			var x=document.getElementById("dcountry");
			x.selectedIndex = 0;
			document.getElementById("conCity").innerHTML='<select id="city" name="city"></select>';
			document.getElementById("conPort").innerHTML='<select id="port" name="port"></select>';
		}
	}
}

var Tracking = {
	myCon:   		false,
	control:		false,
	body:    		false,
	loader:  		false,
	target: 		false,
	content:		false,
	pageURL:		false,
	params: 		false,
	myFuncWhenDone: false,
	
	insertTrackData: function(varIDCampaign, varLocation) {
		if (document.getElementById('txtIDCampaign') != null){
			varIDCampaign = varIDCampaign == '' ?  document.getElementById('txtIDCampaign').value : varIDCampaign;
			D = new Date() 
			Tracking.myCon = new AjaxDell();
			if(!Tracking.myCon) return;
			Tracking.target = '';
			Tracking.params = "action=landing"
			Tracking.params += "&idcampaign=" + varIDCampaign;
			Tracking.params += "&location=" + varLocation;
			Tracking.params += "&time=" + D.getSeconds();
			Tracking.pageURL = "tracking.asp";
			Tracking.myFuncWhenDone = function(xmlObj) {
				
			}
			Tracking.retrieveContent();
		}
	},

	retrieveContent: function() {
			Tracking.myCon.connect(Tracking.pageURL, "Get", Tracking.params, Tracking.myFuncWhenDone);
	},

	retrieveTContent: function() {
		window.location = Tracking.pageURL + '?' + Tracking.params;
	}
}

function landingLogin(){
	var username,pass,blnflagLanding,redirectPage;
	username = document.getElementById("uname").value;
	pass=document.getElementById("pass").value;
	blnflagLanding=document.getElementById("landingflag").value;
	redirectPage=document.getElementById("pageRedirect").value;
	window.location = "my_login.asp?landling_page=" + blnflagLanding + "&id=" + username + "&pass=" + pass + "&pageRedirect=" +redirectPage;
}

function removeElement(){
document.getElementById("promptheader").style.display="none";
}

//Function for getting  available cookies
function getCookie(c_name) {
	if (document.cookie.length>0) {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1) { 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
	  } 
	 }
	return "";
}

//Functioon for Setting Cookies
function setCookie(c_name,value,expiredays) {
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+
	((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
