var newwin_chat;

function dounique()
{ 
	var date = new Date() ; return date.getTime() ; 
}

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=13";
	var sURL = "http://chat.autoterminal.com:8080/Chat/?siteid=13";
	
	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();
	}	
}
	
//for help popup
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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 ValidateField(Field, Restriction)
{
//-----Validate for Null inputs-----
if (Restriction == "Blank")
	{	with (Field) 
		{	if (value==null||value=="")
			 	return false
			else 
				return true
		}
	}
//-----Validate for Email Format-----
if (Restriction == "Email")	
	{	with (Field)
		{	apos = value.indexOf("@")
			dotpos = value.lastIndexOf(".")
			if ( apos<1 || dotpos-apos<2 ) 
				return false
			else 
				return true
		}
	}
//-----Validate for Invalid Character-----
if (Restriction == "InvalidChar")	
	{	var iChars="!#$%^&*()=+{}[]|\;:'/?>,< ";
		var Counter=0;
		var Index=0;
		var errChars=0;
		with (Field)
			{	for (Counter=0;Counter<iChars.length;Counter++)
				{	Index = value.indexOf(iChars.charAt(iChars, Counter));
					if (Index!=-1) errChars = errChars + 1;
				}
				if (errChars > 0)
					return false
				else
					return true
			}
	}
//----- Field Compare (Currently set for Password and Email Only)-----	
if (Restriction == "Compare")	
	{	if ( Field.name == "email") 
			{	if (Field.value == document.getElementById("vemail").value) 
					return true
				else
					return false
			}
		if ( Field.name == "password") 
			{	if (Field.value == document.getElementById("vpassword").value) 
					return true
				else
					return false
			}
	}
//----- Minimun Character Check (Password only) -----	
if (Restriction == "CharCheck")	
	{	with (Field) 
		{	var strValue = value
			if ( strValue.length < 8) 
				return false
			else
				return true
		}
	}
//-----------------------------------------------
}

function formValidate(objForm)
{
var msgError
var Validation

msgError = "The following error(s) occured:\n\n";
with (objForm)
{
if (ValidateField(firstname, "Blank" )==false)
  {	firstname.focus();
	msgError +="- Firstname : Required.\n"
	Validation = false
	}
if (ValidateField(lastname, "Blank" )==false)
  {	lastname.focus();
	msgError +="- Lastname : Required.\n"
	Validation = false
	}
if (ValidateField(company, "Blank" )==false)
  {	company.focus();
	msgError +="- Company : Required.\n"
	Validation = false
	}
if (ValidateField(city, "Blank" )==false)
  {	city.focus();
	msgError +="- City : Required.\n"
	Validation = false
	}
if (ValidateField(password, "Blank" )==false)
  {	password.focus();
	msgError += "- Password : Required.\n"
	Validation = false
	}
if (ValidateField(password, "CharCheck" )==false)
  {	password.focus();
	msgError += "- Password : Minimum of 8 characters.\n"
	Validation = false
	}
}

if (Validation == false)
	{	alert(msgError);
		return false 
	}
}

function switchImage(imgName, imgSrc) 
{  if (document.images)
	 {	if (imgSrc != "none")
			{ document.images[imgName].src = imgSrc;
			}
		}
	}

function PopupImage(strHREF, X, Y){
	if (X == undefined) X = 450;
	if (Y == undefined) Y = 300;
	PopupWin = window.open('', 'mapwin', 'width=' + X + ', height=' + Y)
	PopupWin.document.open()
	PopupWin.document.write('<html><body topmargin="0" leftmargin="0"><center><img src=" ' + strHREF + ' " alt="a car" width="' + X + '" height="'+ Y +'"></img></center></body></html>')
	PopupWin.document.close()
	PopupWin.resizeTo(X, Y + 25)
	PopupWin.focus()
}	
function ToMed(str){
	str=str.toLowerCase();
	return str.replace("small","medium");
}
// 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);
}

/* MH added this script */
function showNote(idv)
	{		
		document.getElementById('note_' + idv).style.display='block'
	}
function hideNote(idv)
	{
		document.getElementById('note_' + idv).style.display='none'
	}

/*End here */

/* MH added this script for Tooltip */
/* **********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
********************************************** */
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}	

function showtip(thetext, thecolor, thewidth){	
	var containerTemp;
	if (ns6||ie){
	if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
	if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
	
	containerTemp = "<div id='note_Grade2' >";
	containerTemp = containerTemp + thetext;
	containerTemp = containerTemp + "</div>";
	tipobj.innerHTML=containerTemp;
	
	//alert( document.getElementById("note_Grade2").style.visibility );
	
	//document.getElementById("note_Grade2").style.top = 500+"px";
	//alert( document.getElementById("note_Grade2").style.top );
	
	//document.onmousemove=getMouseCoordinates;
	
	//getMouseCoordinates(document.onmousemove);
	
	enabletip=true
	return false
	}
}

function getMouseCoordinates(event)
{	
	var ypos;
	ev = event || window.event;
	ypos = ev.pagey;
	alert(event);
	//document.getElementById("note_Grade2").style.top = ypos+"px";

}

function positiontip(e){
	if (enabletip){
	var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
	var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
	//Find out how close the mouse is to the corner of the window
	var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
	var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

	var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000

	//if the horizontal distance isn't enough to accomodate the width of the context menu
	if (rightedge<tipobj.offsetWidth)
	{
	//move the horizontal position of the menu to the left by it's width
	tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
	}
	else if (curX<leftedge)
	{
	
	tipobj.style.left="5px"
	}
	else
	{
	//position the horizontal position of the menu where the mouse is positioned
		tipobj.style.left=100+curX+offsetxpoint+"px";
		if(document.getElementById("note_Grade2") != null)
			{
				document.getElementById("note_Grade2").style.left=(curX-400)+"px";
				document.getElementById("note_Grade2").style.top=(curY-130)+"px";
			}
	}

	//same concept with the vertical position
	if (bottomedge<tipobj.offsetHeight)
	tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
	else
	tipobj.style.top=curY+offsetypoint+"px"
	tipobj.style.visibility="visible"
	}
}

function hidetip(){
	if (ns6||ie){
	enabletip=false
	tipobj.style.visibility="hidden"
	tipobj.style.left="-1000px"
	tipobj.style.backgroundColor=''
	tipobj.style.width=''
	}
}

function showhide(mymessage){
	document.getElementById('fileId').value=mymessage;
	document.getElementById('filename').innerHTML=mymessage;
	document.getElementById('showdelete').style.display='block';
	document.getElementById('ttfilelist').style.display='none';
}		

function incs(){
	var x,getmevalue;
	getmevalue=parseInt(document.getElementById("getme").value);
	getmevalue=getmevalue + 1;
	
	document.getElementById("mydiv").innerHTML = document.getElementById("mydiv").innerHTML + "<span class='style6'>File" + getmevalue + ": </span> <input 		type='file' id=file" + getmevalue +" name=file"+ getmevalue +" value=''><br><br>";
	document.getElementById("getme").value=parseInt(getmevalue);
}

function divloader(){
	var tempvar;
	document.getElementById("showloader").innerHTML='<font size=4 color=black><br /><br />Checking File Please Wait...</font><br /><br /><img id="main" src="../images/loader/ajax-loader1.gif">';
	document.getElementById("mydiv").style.display='none';
	document.getElementById("mydiv1").style.display='none';
	document.getElementById("mydiv2").style.display='none';
	document.getElementById("mydiv3").style.display='none';
}

function recommendFriend(){
		var sURL;		
		sURL="recommend_a_friend.asp";
		var isMozilla;
		isMozilla = (document.all) ? 0 : 1;	
		if (!newwin_chat || newwin_chat.closed) {
				
			if (isMozilla) {       
				newwin_chat = window.open(sURL,'','toolbars=no,menubar=no,resize=no,scrollbars = no, status = no, resizable = no,name=ts,width=450,height=450,screenX=400,screenY=200');
			}else{
				newwin_chat = window.open(sURL,'','toolbars=no,menubar=no,scrollbars = no, status = no, resizable = no,name=ts,width=450,height=450,left=350,top=250');
			}	
					
			if(newwin_chat) newwin_chat.focus();
		}else{
			if(newwin_chat) newwin_chat.focus();
		}
		
		newwin_chat.document.title = "Recommend A Friend";
		
}

//ADDED BY MELCHOR B. PINEDA JR.
// Scripts For Manipulating Country Region Point
var tester
tester=1;

function showCountryData(){
	document.getElementById("ctryList").style.display="block";		
}

function hideCountryData(){
	document.getElementById("ctryList").style.display="none";	
}
  
  
function countryHover(id){
	document.getElementById("selectedCountry").value=document.getElementById(id).innerHTML;
}

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 setValue(val,country){
	var str = country;  
	var result = str.replace(/_/gi, " ");
    var strValue=val;
	var ctryArray = strValue.replace(/_/gi, " ");
	
	document.getElementById("ctryList").style.display="none";
	document.getElementById("REGION").value=ctryArray;
	redirectLocation(result);
}


function redirectLocation(val){ 

	var strRegion,region_text;	
	
	strRegion=document.getElementById("REGION").value;
	//MDH added the condition for IBC Russia //
	if(val == 'Russia' && strRegion == 'Other'){
		strRegion="Russia"
	}
	//IBC Russia Ends here //

	if(strRegion.search(/Africa/) > -1 ){
		region_text="Africa";
	}else if(strRegion.search(/North America/) > -1 ){
		region_text="NAmericas";
	}else if(strRegion.search(/Caribbean/)> -1 ){
		region_text="Caribbean";
	}else if(strRegion.search(/Asia/) > -1 ){
		region_text="Asia";
	}else if(strRegion.search(/Australia/)> -1 ){
		region_text="Australia";
	}else if(strRegion.search(/Europe/)> -1 ){
		region_text="Europe";
	}else if(strRegion.search(/New Zealand/)> -1 ){
		region_text="New Zealand";
	}else if(strRegion.search(/Oceania/)> -1 ){
		region_text="Oceania";
	}else if(strRegion.search(/Russia/)> -1 ){
		region_text="Russia";
	}else if(strRegion.search(/Japan/)> -1 ){
		region_text="Japan";
	}else if(strRegion.search(/South America/)> -1 ){
		region_text="SAmericas";
	}else if(strRegion.search(/UK/)> -1 ){
		region_text="Europe";
	}else{
		region_text="Asia";
	}
	
	
switch (region_text){ 
		case "Africa" :
			pageURL_1 = "/ataf/home.asp";
			betaURL = "betaafrica.autoterminal.com/home.asp";
			liveURL = "africa.autoterminal.com/home.asp";
			break;
		case "NAmericas" :
			pageURL_1 = "/ata/home.asp";
			betaURL = "betaamericas.autoterminal.com/home.asp";
			liveURL = "americas.autoterminal.com/home.asp";

			break;
		case "Caribbean" :
			pageURL_1 = "/ata/home.asp";
			betaURL = "betaamericas.autoterminal.com/home.asp";
			liveURL = "americas.autoterminal.com/home.asp";

			break;
		case "SAmericas" :
			pageURL_1 = "/atsam/home.asp";
			betaURL = "betasouthamerica.autoterminal.com/home.asp";
			liveURL = "southamerica.autoterminal.com/home.asp";

			break;
		case "Asia" :
			pageURL_1 = "/oth/home.asp";
			betaURL = "betaasia.autoterminal.com/home.asp";
			liveURL = "asia.autoterminal.com/home.asp";

			break;
		case "Australia" :
			pageURL_1 = "/atoz/home.asp";
			betaURL = "betaaustralia.autoterminal.com/home.asp";
			liveURL = "australia.autoterminal.com/home.asp";

			break;
		case "Europe" :
			pageURL_1 = "/atuk/home.asp";
			betaURL = "betaunitedkingdom.autoterminal.com/home.asp";
			liveURL = "unitedkingdom.autoterminal.com/home.asp";

			break;
		case "New Zealand" :
			pageURL_1 = "/atnz/home.asp";
			betaURL = "betanewzealand.autoterminal.com/home.asp";
			liveURL = "newzealand.autoterminal.com/home.asp";

			break;
		case "Oceania" :
			pageURL_1 = "/oth/home.asp";
			betaURL = "betaasia.autoterminal.com/home.asp";
			liveURL = "asia.autoterminal.com/home.asp";

			break;
		case "Russia" :
			pageURL_1 = "/oth/home.asp";
			betaURL = "betaasia.autoterminal.com/home.asp";
			liveURL = "asia.autoterminal.com/home.asp";

			break;
		case "UK, Ireland, Cyprus" :
			pageURL_1 = "/atuk/home.asp";
			betaURL = "betaunitedkingdom.autoterminal.com/home.asp";
			liveURL = "unitedkingdom.autoterminal.com/home.asp";

			break;
		case "Japan" :
			pageURL_1 = "/oth/home.asp";
			betaURL = "betaasia.autoterminal.com/home.asp";
			liveURL = "asia.autoterminal.com/home.asp";

			break;
		default:
			pageURL_1 = "/oth/home.asp";
			betaURL = "betaasia.autoterminal.com/home.asp";
			liveURL = "asia.autoterminal.com/home.asp";

	}
	
		//document.getElementById("REDIRECT").value=pageURL_1;
		//temporary http://192.168.23.184:8081 -- change this with your local port 
		//to http://www.autoterminal.com when deploying to live
		
		 var yLocation = location.href ;
		 var answer = yLocation.search("beta");
		 if (answer > -1){
			window.location.href = "http://" + betaURL;
		 }else{
			//window.location.href = "http://192.168.23.184:8081" +pageURL_1;
			window.location.href = "http://" + liveURL;
		 }
}

