function UpdateQty(item)
		{
			itemId = item.name;
			newQty = item.options[item.selectedIndex].text;
			
			document.location.href = 'cart.php?action=update_item&id='+itemId+'&qty='+newQty;
		}	
		
function UpdateShip(ship)
		{
			newShip = ship.options[ship.selectedIndex].value;
			document.getElementById('myShipping').innerHTML = newShip;
			document.location.href = 'checkout_final.php?ship='+newShip;

		}	

function submitform()
{
	for (i=0; i < document.forms.length; i++)
    {
     document.forms[i].submit();
    } 
	

}

function showMe (it, box) 
		{ 
			var vis = (box.checked) ? "block" : "none"; 
			document.getElementById(it).style.display = vis;
		} 


function goShopping()
		{
			var x=document.getElementById('shopping');
			if(x)
			{
				document.location.href = '/order/checkout.php';
				return true;
			}
			else
			{
				alert("Please Add an Item to your Cart");
				return false;
			}
		}	// goShopping


function blankRef()
	{
		// code here...
	}
// href="#" onclick="blankRef();return false;"


var message="Sorry, Right-Click is Disabled.\n\nCopyright Protected by VLine LLC © 2007";
function clickIE(){
	if (document.all)
		{(message);return false;}}
function clickNS(e) {
	if (document.layers||(document.getElementById&&!document.all))
		{ if (e.which==2||e.which==3) {(message);return false;}}}
		if (document.layers) {
		document.captureEvents(Event.MOUSEDOWN);document.  onmousedown=clickNS;}
	else
		{document.onmouseup=clickNS;document.oncontextmenu  =clickIE;}
		document.oncontextmenu=new Function("return false")


if (document.images)
	{
      preload_image_object = new Image();
      // set image url
      image_url = new Array();
      image_url[0] = "imgs/";
      image_url[1] = "imgs/";
      image_url[2] = "imgs/";
      image_url[3] = "imgs/";
      image_url[4] = "imgs/";
      image_url[5] = "imgs/";

       var i = 0;
       for(i=0; i<=5; i++) 
         preload_image_object.src = image_url[i];
	   	 
    }  




function toggleDiv(id,flagit) {
if (flagit=="1"){
if (document.layers) document.layers[''+id+''].visibility = "show"
else if (document.all) document.all[''+id+''].style.visibility = "visible"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "visible"
}
else
if (flagit=="0"){
if (document.layers) document.layers[''+id+''].visibility = "hide"
else if (document.all) document.all[''+id+''].style.visibility = "hidden"
else if (document.getElementById) document.getElementById(''+id+'').style.visibility = "hidden"
}
}


function Initialize(path)
{

    DeleteCookie("Top");
    DeleteCookie("Bottom");
	DeleteCookie("BagSize");
    DeleteCookie("Straps");
    DeleteCookie("ScreenLogo");
    DeleteCookie("Outer");
    DeleteCookie("Inner");
    DeleteCookie("Accent");
	DeleteCookie("Shell");
    DeleteCookie("Mess_Front");
    DeleteCookie("Mess_Shoulder");
    DeleteCookie("Mess_Buckle");
    DeleteCookie("Lining");
    DeleteCookie("Powdercoat");
    DeleteCookie("LaptopSleeve");
	DeleteCookie("CellHolster");
	DeleteCookie("Pot_Top");
    DeleteCookie("Pot_Bottom");
	DeleteCookie("Pot_Back");
	DeleteCookie("Pot_PocketSide");
    DeleteCookie("Pot_Side");
	DeleteCookie("CBag_Top");
	DeleteCookie("CBag_Bottom");
	

  // EraseAllCookies
	
	
	/* Get cookie string and separate into individual cookie phrases:
	var cookie_string = "" + document . cookie;
	var cookie_array = cookie_string . split ("; ");

	// Try to delete each cookie:
	for (var i = 0; i < cookie_array . length; ++ i)
	{
		var single_cookie = cookie_array [i] . split ("=");
		if (single_cookie . length != 2)
			continue;
		var name = unescape (single_cookie [0]);
		delete_cookie (name, path);
	}*/
	
	
	for (i=0; i < document.forms.length; i++)
    {
     document.forms[i].reset();
    }
}


function changepic()
{
	var x = document.getElementById("pickcolor").value;
	toggleDiv(x,0)
		alert(x)

	obj = toggleDiv(x,1)
	return true;
}


if (document.images)
	{
      preload_image_object = new Image();
      // set image url
      image_url = new Array();
      image_url[0] = "imgs/red.gif";
      image_url[1] = "imgs/green.gif";
      image_url[2] = "imgs/yellow.gif";
      image_url[3] = "imgs/blue.gif";
	  
       var i = 0;
       for(i=0; i<=3; i++) 
         preload_image_object.src = image_url[i];
	   	 
    }  



function dropdown(sel){ 
//   	c = confirm('You choose ' + sel.options[sel.selectedIndex].innerHTML + '\nDo you want to continue?'); 
      
	  
//      if(c)
//	  { 
	  	var color = sel.options[sel.selectedIndex].innerHTML;
		
		var today = new Date();
		var expire = new Date();
 			expire.setTime(today.getTime() + 1000 * 60 * 60 * 24 * 1);  // 1 days
 			
			document.cookie = "myColor="+color+";expires="+expire.toGMTString();
//	  } else { sel.selectedIndex = 0; } 
} 

	
function swap1(source) {
    if (document.images) {
		document.images['myImage1'].src = source;
		 // document.cookie = "logged_in="+source;
    }
}
function swap2(source) {
    if (document.images) {
        document.images['myImage2'].src = source;
    }
}


function DeleteCookie(TheName)
{
   // These two lines will make an expiration date
   // Yesterday which will delete the cookie entry
   var Expiration = new Date();
   Expiration.setTime (Expiration.getTime() - 1);
   // Encode the name to make sure it can be found
   EncodedName=escape(TheName)
   // Update The cookie with new Expiration date
   // Which will cause the browser to delete it
   document.cookie = EncodedName + "=" +
   " " + 
   "; expires=" + Expiration.toGMTString();  

} // DeleteCookie


/*
function submitform()
  {
	  document.forms['form2'].submit()
  }
	*/
	

var IFrameObj; // our IFrame object
function callToServer(theFormName) {
	if (!document.createElement) {return true};
	var IFrameDoc;
	
	// We'll build our URL by checking which state
	/* has been selected in the drop down menu
	var stateEl = document.forms[theFormName].state
	var theState = stateEl.options[stateEl.selectedIndex].value
	if (theState=='') {return false}; // no state has been selected
	var URL = "states/"+theState+".html" */
	
	//provide a "loading" message
	var responseMessage = document.getElementById('responseMessage');
	responseMessage.style.display = 'inline';
	responseMessage.innerHTML = "<font style='font-size:.7em;'>checking code...</font>";
	
	var promocode = document.frmOrder.promo.value;
	// alert(promocode);
	var URL = "mypage.php?code="+promocode; 
	document.getElementById('Updater').src  = URL;
	

	
	/*
	if (!IFrameObj && document.createElement) {
		// create the IFrame and assign a reference to the
		// object to our global variable IFrameObj.
		// this will only happen the first time 
		// callToServer() is called
		try {
			var tempIFrame=document.createElement('iframe');
			tempIFrame.setAttribute('id','RSIFrame');
			tempIFrame.style.border='0px';
			tempIFrame.style.width='0px';
			tempIFrame.style.height='0px';
			IFrameObj = document.body.appendChild(tempIFrame);
			
			if (document.frames) {
				// this is for IE5 Mac, because it will only
				// allow access to the document object
				// of the IFrame if we access it through
				// the document.frames array
				IFrameObj = document.frames['RSIFrame'];
			}
		} catch(exception) {
			// This is for IE5 PC, which does not allow dynamic creation
			// and manipulation of an iframe object. Instead, we'll fake
			// it up by creating our own objects.
			iframeHTML='<iframe id="RSIFrame" style="';
			iframeHTML+='border:0px;';
			iframeHTML+='width:0px;';
			iframeHTML+='height:0px;';
			iframeHTML+='"><\/iframe>';
			document.body.innerHTML+=iframeHTML;
			IFrameObj = new Object();
			IFrameObj.document = new Object();
			IFrameObj.document.location = new Object();
			IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
			IFrameObj.document.location.replace = function(location) {
				this.iframe.src = location;
			}
		}
	}
	
	if (navigator.userAgent.indexOf('Gecko') !=-1 && !IFrameObj.contentDocument) {
		// we have to give NS6 a fraction of a second
		// to recognize the new IFrame
		setTimeout('callToServer("'+theFormName+'")',10);
		return false;
	}
	
	if (IFrameObj.contentDocument) {
		// For NS6
		IFrameDoc = IFrameObj.contentDocument; 
	} else if (IFrameObj.contentWindow) {
		// For IE5.5 and IE6
		IFrameDoc = IFrameObj.contentWindow.document;
	} else if (IFrameObj.document) {
		// For IE5
		IFrameDoc = IFrameObj.document;
	} else {
		return true;
	}
	
	IFrameDoc.location.replace(URL);
	return false;
}

// handleResponse is passed two parameters when called from the onload
// event of the pages loaded in the hidden IFRAME:
//	st: a string indicating which state is being loaded
//	doc: the document object of the page loaded in the IFRAME
function handleResponse(st, doc) {
	// get a reference to the multiple select list, which we will populate
	// with the data from the document loaded in the IFRAME
	var namesEl = document.forms.stateForm.zipNames
	
	// clear earlier records from the multiple select list
	namesEl.length = 0
	
	// get a reference to the DIV containing the data for this state
	var dataEl = doc.getElementById(st)
		
	// get a reference to the collection of the children elements of
	// our DIV containing the data (this collection is the DIVs containing
	// the actual zip names)
	namesColl = dataEl.childNodes
	
	// for easy scripting, assign the number of ZIP names for this state
	// to a variable
	var numNames = namesColl.length
	
	// iterate through the collection of zip Names and
	// create an option element for each one
	for (var q=0; q<numNames; q++) {
		if (namesColl[q].nodeType!=1) continue; // it's not an element node, let's skedaddle
		var str = '' // used to store the text we'll use in the new option
		str+= namesColl[q].id + ' ('
		
		// get a reference to the collection of the children elements of
		// this DIV (this collection contains the zip codes that fall under this zip name)
		
		var zipsColl = doc.getElementById(namesColl[q].id).childNodes
		var numZips = zipsColl.length
		
		// iterate through this collection of zips and each one to the string
		for (var r=0; r<numZips; r++) {
			if (zipsColl[r].nodeType!=1) continue; // it's not an element node, let's skedaddle
			str += zipsColl[r].id + ' '
			}
		str+= ')'
		
		// create a new option element and add it to the zipNames form element
		newOption = new Option(str)
		namesEl.options[namesEl.length] = newOption
		}
	
	//provide a "success" message
	var responseMessage = document.getElementById('responseMessage');
	responseMessage.innerHTML = 'loaded records from <a href="'+doc.location+'">this external file<\/a>.';
*/
}

// handleResponse is passed two parameters when called from the onload
// event of the pages loaded in the hidden IFRAME:
//	st: a string indicating which state is being loaded
//	doc: the document object of the page loaded in the IFRAME
function handleResponse(percent) {
	// get a reference to the multiple select list, which we will populate
	// with the data from the document loaded in the IFRAME


	//provide a "success" message
	var responseMessage = document.getElementById('responseMessage');
	responseMessage.style.display = 'inline';
	responseMessage.innerHTML = "<font style='font-size:.7em;'>Approved Code!</font>";
	
	var getCurrentURL = document.getElementById('mytotal').src;
	var thenewURL = getCurrentURL+"&discount="+percent; 
	document.getElementById('mytotal').src  = thenewURL;
	document.getElementById('gotPromo').value = "yes";	
	/*var promoText = document.getElementById('promoText');
	promoText.style.display = 'inline';
	var promoPercent = document.getElementById('promoPercent');
	var viewPercent = parseFloat(percent);
	var viewPercent = viewPercent*100;
	promoPercent.innerHTML = "<b>"+viewPercent+"&nbsp;%</b>";
	promoPercent.style.display = 'inline';
	
		oldtotal = document.getElementById('grandTotal').innerHTML;
		oldtotal2 = parseFloat(oldtotal);
		percent2 = parseFloat(percent);
		//oldtotal2 = Math.round(oldtotal*100/100);
		var total2 = Math.round(oldtotal2 * percent2 * 100)/100;
		total3 = Math.round((oldtotal - total2) * 100)/100;
		
		// var total = Math.round(oldtotal - (oldtotal * percent) * 100) / 100;
		
		
		document.getElementById('grandTotal').innerHTML = total3; */
	
	document.getElementById('checkpromo').setAttribute('href','javascript:window.alert("Your Code is Already Approved");')

}

function falseResponse() {
	// get a reference to the multiple select list, which we will populate
	// with the data from the document loaded in the IFRAME
	
	//provide a "success" message
	var responseMessage = document.getElementById('responseMessage');
	responseMessage.style.display = 'inline';
	responseMessage.innerHTML = "<font style='font-size:.7em;'>Invalid Code</font>";
	/*var promoText = document.getElementById('promoText');
	promoText.style.display = 'none';
	var promoPercent = document.getElementById('promoPercent');
	promoPercent.style.display = 'none';
	
	document.getElementById('grandTotal').innerHTML = oldtotal;*/
}

function noResponse() {
	// get a reference to the multiple select list, which we will populate
	// with the data from the document loaded in the IFRAME
	
	//provide a "success" message
	var responseMessage = document.getElementById('responseMessage');
	responseMessage.style.display = 'none';
}

function retrieveNewTotal(newsubtotal,newship,newtax,newtotal) {
	// get a reference to the multiple select list, which we will populate
	// with the data from the document loaded in the IFRAME
	//alert(newtotal);
	document.getElementById('newSubtotal').value = newsubtotal;
	document.getElementById('newShipping').value = newship;
	document.getElementById('newTax').value = newtax;
	document.getElementById('newTotal').value = newtotal;

}


function callToCustomText(theFormName) {
	if (!document.createElement) {return true};
	var IFrameDoc;
	
	var gotURL = document.getElementById('Updater').src
	var URL = gotURL+"&id=yes"; 
	document.getElementById('Updater').src  = URL;
}
	