/*--------------------------------------------
//
// scripts.js ver. 1.1 ES3 TM
// Summary: General Scripts
//
//------------------------------------------*/


//Image Pre-Cache
//start precache
if (document.images)
{
  pic1= new Image(99,27); 
  pic1.src="images/tabs/red_on.png"; 

  pic2= new Image(78,27); 
  pic2.src="images/tabs/purple_on.png"; 

  pic3= new Image(115,27); 
  pic3.src="images/tabs/green_on.png"; 
  
  pic4= new Image(113,27); 
  pic4.src="images/tabs/copper_on.png"; 
  
  pic5= new Image(99,27); 
  pic5.src="images/tabs/blue_on.png"; 
  
  pic6= new Image(114,27); 
  pic6.src="images/tabs/bronze_on.png"; 
}
//end precache



// Global Variables

var ie = (document.all)?true:false;									// IE 4+
var ns = (document.layers)?true:false;	
var moz = (document.getElementById && !document.all)?true:false;	// Mozilla 5.x / NS 6



var myWindow;
function openWin(url,w,h) {
	var	ranNum=parseInt(Math.random()*255);
	/*
	w = 650;
	h = 600;
	*/
	l=screen.width/2-w/2;
	t=screen.height/2-h/2;
	
	if (typeof myWindow == "object") {
		myWindow.close();	
	}
	myWindow = window.open(url,'admintronwin'+ranNum,'top='+t+',left='+l+',height='+h+',width='+w+',noresize,scrollbars=yes,status=yes');
}

function GotoPage(pageURL)
{
     window.location.href=pageURL;
}



function openNewWindow(theURL) { //v2.0
  window.open(theURL);
}


function openWinZoom(url,w,h) {

	var	ranNum=parseInt(Math.random()*255);
	/*
	w = 650;
	h = 600;
	*/
	l=screen.width/2-w/2;
	t=screen.height/2-h/2;
	
	if (typeof myWindow == "object") {
		myWindow.close();	
	}
	myWindow = window.open(url,'admintronwin'+ranNum,'top='+t+',left='+l+',height='+h+',width='+w+',noresize,scrollbars=yes,location=no,status=yes,toolbar=no,menubar=no,resizable=no,status=no');
}

 


//Launch Window for Techshowcase with scrolling off//

var myWindowb;
function openWinb(url,w,h) {
	var	ranNum=parseInt(Math.random()*255);
	/*
	w = 650;
	h = 600;
	*/
	l=screen.width/2-w/2;
	t=screen.height/2-h/2;
	
	if (typeof myWindowb == "object") {
		myWindowb.close();	
	}
	myWindowb = window.open(url,'admintronwin'+ranNum,'top='+t+',left='+l+',height='+h+',width='+w+',noresize,scrollbars=no,status=no');
}
//end//


function showLogin(){
	document.getElementById("login").style.display = "block";
	document.getElementById("loginLink").style.display = "none";
	//document.getElementById("mylogin").value = "true";
}

 function submitType(type){
	if (type == '3'){
		//openWin('/caltotal.aspx?txtPromoCode='+document.forms.catinfo.txtPin1.value+document.forms.catinfo.txtPin2.value+document.forms.catinfo.txtPin3.value+'','430','280')
		openWin('/caltotal.aspx','440','280')
		document.forms.catinfo.submitType.value = '1';
		document.forms.catinfo.submit();
	}
	else if (type == '5'){
		//openWin('/caltotal.aspx?txtPromoCode='+document.forms.catinfo.txtPin1.value+document.forms.catinfo.txtPin2.value+document.forms.catinfo.txtPin3.value+'','430','280')
		openWin('/caltotal_focus.aspx','440','280')
		document.forms.catinfo.submitType.value = '1';
		document.forms.catinfo.submit();
	}
	else{
		document.forms.catinfo.submitType.value = type;
		document.forms.catinfo.submit();
	}
 }
 
 //AutoTab the field to the next one
var code_field_length=0;
function TabNext(obj,event,len,next_field) {
	if (event == "down") {
		//obj.value=obj.value.toUpperCase();
		code_field_length=obj.value.length;
		}
	else if (event == "up") {
		if (obj.value.length != code_field_length) {
			code_field_length=obj.value.length;
			if (code_field_length == len) {
				obj.value=obj.value.toUpperCase();
				next_field.focus();
				}
			}
		}
	}


function Trim(s) 
{
  // Remove leading spaces and carriage returns
  while ((s.substring(0,1) == ' ') || (s.substring(0,1) == '\n') || (s.substring(0,1) == '\r'))
  {
    s = s.substring(1,s.length);
  }
  // Remove trailing spaces and carriage returns
  while ((s.substring(s.length-1,s.length) == ' ') || (s.substring(s.length-1,s.length) == '\n') || (s.substring(s.length-1,s.length) == '\r'))
  {
    s = s.substring(0,s.length-1);
  }
  return s;
}

// Wait Function for pasting into multiple fields
function pasteCode() {
	setTimeout("pasteCodeAfter()",10);
}

//Paste Into mulitple fields (PIN)
function pasteCodeAfter() {
	var code = Trim(window.clipboardData.getData("Text"));
	var codeSplit;
	if (code.length == 20) {
		codeSplit = code.split("-");
		document.forms[0].txtPin1.value=codeSplit[0];
		document.forms[0].txtPin2.value=codeSplit[1];
		document.forms[0].txtPin3.value=codeSplit[2];
		document.forms[0].txtPin3.focus();
	}	
}


