var newwin_chat;
var OfferDivID;
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=11";
	
	//var sURL= "http://chat.autoterminal.com:8080/Chat/?siteID=11";
	var sURL = "http://chat.autoterminal.com:8080/Chat/?siteid=11";
	
	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 atozshowMessage() {
		OfferDivID = "greetingMessage";
		
		valMessage ="Important Announcement";
		
		valMessage ="Important Announcement<br /><br />";
		valMessage +="We would like to inform you that AutoTerminal.com Australia’s customer service will not be available during the holidays on the following dates:<br /><br />";
		valMessage +="<b>December 21, 2007 up to January 6, 2008.</b><br />";
		valMessage +="We are open and can work with you during any time outside those shown during the holiday season.<br /><br />";
		valMessage +="If needed, please feel free to email your queries and concerns to <a href=mailto:atozsales@autoterminal.com>atozsales@autoterminal.com</a> and we will gladly attend to them immediately upon resumption of operations.<br /><br />";
		valMessage +="Happy Holidays to everyone from AutoTerminal.com Australia!<br /><br />";
			
		loader = document.getElementById(OfferDivID);
		loader.style.visibility	= 'visible';
		loader.style.position   = 'absolute';
		loader.style.top        = 310 + 'px'; // yBase
		loader.style.left       = 550 + 'px'; //xBase
		loader.style.width      = '505px';

		loader.style.padding    = '2px';
		loader.style.margin     = '-50px 0 0 -150px';
		loader.style.border     = '1px solid #000000';
		loader.style.background = '#ffffff';
		loader.style.font	   = 'bold 12px Verdana, Arial, Helvetica, sans-serif;';
		document.getElementById('greetingMsg').innerHTML = valMessage
	
	
		var Xpos, Ypos, yBase, xBase;
		isMozilla = (document.all) ? 0 : 1;
		if (isMozilla) {
			Xpos = document.body.scrollLeft;
			Ypos = document.body.scrollTop;
			yBase = (window.document.body.offsetHeight/8) + Ypos + 20;
			xBase = (window.document.body.offsetWidth/3) + Xpos + 50;
			if (yBase < 100) yBase = 310;
		}
		else {
			Xpos = document.body.scrollLeft;
			Ypos = document.body.scrollTop;
			yBase = (window.document.body.offsetHeight/2) + Ypos + 32;
			xBase = (window.document.body.offsetWidth/3) + Xpos + 50;
		}
}

function closeMessage() {
	loader = document.getElementById(OfferDivID);
	loader.style.visibility	= 'Hidden';
	document.getElementById('greetingMsg').innerHTML = "";
}

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());
}
