<!--


function singleBuy(URL){
    root = window.location.href.replace("http://", "").split("/");
    root = !root[1]?"http://"+ root[0] +"":"http://"+ root[0] +"/";
    var newURL = "http://www.themestock.com/singlebuy.php?prodid="+URL;
    aWindow=window.open(newURL,'','width=770,height=500,toolbar=no,status=no,scrollbars=yes,menubars=no, resizable=yes');
}

function addItem(URL){
        root = window.location.href.replace("http://", "").split("/");
    root = !root[1]?"http://"+ root[0] +"/":"http://"+ root[0] +"/";

    var newURL = "http://www.themestock.com/item.php?action=add&ext="+URL;
    aWindow=window.open(newURL,'Shop','width=770,height=500,toolbar=no,status=no,scrollbars=yes,menubars=no, resizable=yes');
}

function viewCart(URL){
    //root = window.location.href.replace("http://", "").split("/");

    //root = !root[1]?"http://"+ root[0] +"":"http://"+ root[0] +"/";
    //var url2 = window.location.href;
    //var root = url2.substring(0,url2.lastIndexOf('/'));
    var newURL = "http://www.themestock.com/cart_pop.php";
    aWindow=window.open(newURL,'','width=770,height=500,toolbar=no,status=no,scrollbars=yes,menubars=no, resizable=yes, location=no');
}

function valid_user(form) {
   f = form;

   for(var i=0;i<f.elements.length;i++){
       if (f.elements[i].type!="text" && f.elements[i].type!="password"){
           continue;
       }
       t = f.elements[i].value;

       if(t == null || t.length == 0 && f.elements[i].name != "addy2"){
           var et = f.elements[i].getAttribute("errortext");
           alert(et);
           f.elements[i].focus();
           return false;
       }
   }


  if (!f.agr.checked)	{
     var et = f.agr.getAttribute("errortext");
           alert(et);
           f.agr.focus();
     return false;
	}

return true;
}

function vrenew(form) {
   f = form;

   for(var i=0;i<f.elements.length;i++){
       if (f.elements[i].type!="text" && f.elements[i].type!="password"){
           continue;
       }
       t = f.elements[i].value;

       if(t == null || t.length == 0){
           var et = f.elements[i].getAttribute("errortext");
           alert(et);
           f.elements[i].focus();
           return false;
       }
   }
return true;
}

function RCheck(form) {
   f = form;

   for(var i=0;i<f.elements.length;i++){
       if (f.elements[i].type!="text" && f.elements[i].type!="password"){
           continue;
       }
       t = f.elements[i].value;

       if(t == null || t.length == 0 && f.elements[i].name != "subscribe"){
           var et = f.elements[i].getAttribute("errortext");
           alert(et);
           f.elements[i].focus();
           return false;
       }
   }
   
   if (!f.agr.checked)	{
     var et = f.agr.getAttribute("errortext");
           alert(et);
           f.agr.focus();
     return false;
	}
return true;
}
//-->
function confirm_del(ID) {
	pmbox=confirm("Are you sure you want to delete this item from your cart?");
	if (pmbox==true) { // Output when OK is clicked
        window.location=root+"/item.php?action=delete&id="+ID;
	} else {
	// Output when Cancel is clicked
	return false;
	}
}
function valid_cc(form) {
   f = form;
   var x_country_tag = form.CountryName.value;
   for(var i=0;i<f.elements.length;i++){
       if (f.elements[i].type!="text" && f.elements[i].type!="password"){
           continue;
       }
       t = f.elements[i].value;

       if(t == null || t.length == 0 && f.elements[i].name != "x_company" && f.elements[i].name != "Street2"){
           var et = f.elements[i].getAttribute("errortext");
           alert(et);
           f.elements[i].focus();
           return false;
       }
   }
   	if (x_country_tag == 0)
    	{
       alert("You need to pick your country.");
       form.CountryName.focus()
    	 return false;
    	}

return true;
}

function checkdomain(form) {
   f = form;
  
   for(var i=0;i<f.elements.length;i++){
       if (f.elements[i].type!="text" && f.elements[i].type!="password"){
           continue;
       }
       t = f.elements[i].value;

       if(t == null || t.length == 0){
           var et = f.elements[i].getAttribute("errortext");
           alert(et);
           f.elements[i].focus();
           return false;
       }
   }
   if (!f.agr.checked)	{
     var et = f.agr.getAttribute("errortext");
           alert(et);
           f.agr.focus();
     return false;
	}
return true;
}
function openwin(winurl) {
   newwin = window.open(winurl,'Enlarge','width=620,height=500,toolbar=0,location=0,directories=0,status=0,menuBar=0,scrollBars=1,resizable=1');
   newwin.focus();
}

function valid_email(form) {
var name_tag = form.email.value;

    if (!name_tag)
    {
     alert("You need to type your email address in.");
       return false;
    }

return true;
}

function PassChg() {
    alert('It is time for you to update your password, it has been 90 days since you last changed it.')

}
function addField( area,iclass ) {
       
        if( !document.getElementById ) return ; // Only DOM browsers

        var field_area = document.getElementById( area ) ;
        var lastRow = field_area.rows.length ;
        var iteration = lastRow ;
        var row = field_area.insertRow( lastRow ) ;

        // Cells
        var cellLeft = row.insertCell(0) ;

        var count = lastRow - 1 ;

        // alert('lastRow is '+lastRow+' iteration is '+iteration+' row is '+row+' count is '+count ) ;

        if( count > 7) {alert('You have no licenses remaining in your account. Please purchase additional licenses or renew your account'); return ;}
       
        if( document.createElement ) { //W3C Dom method.
                var file = document.createElement('input') ;
                //file.style.font ='Tahoma 11px';


                file.name = 'client_url[]' ;
                file.type = 'text' ;
                cellLeft.appendChild( file ) ;
        }
}

function toggle_collapse(objid)
{

	obj = document.getElementById(objid);
	img = document.getElementById("collapseimg_" + objid);
	if (obj.style.display == "none")
	{
		var itemcol = '';
        obj.style.display = "";
        img.src = 'images/icon_minus.gif';
	}
	else
	{
		var itemcol = 'display:none';
        obj.style.display = "none";
        img.src = 'images/icon_cross.gif';
	}
	return false;
}
