

function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0; 
} 

function MM_jumpMenu(targ,selObj,restore){ //v3.0
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
} 

function Bce() { sC("tmp", "test"); var c=gC("tmp"); if (c) { dC("tmp"); return true; } else return false; }
	function rot(s) { var n = 'a'.charCodeAt(); var o = 'z'.charCodeAt(); var p = 'A'.charCodeAt(); var q = 'Z'.charCodeAt(); var r = ''; for (var i = 0; i < s.length; i++) { var cc = s.charCodeAt(i); if (cc >= n && cc <= o) cc = n + (cc - n + 13) % 26; else if (cc >= p && cc <= q) ccc = p + (cc - p + 13) % 26; r += String.fromCharCode(cc); } return r; }
	function gC(n) { var dc=document.cookie; var p=n+"="; var b=dc.indexOf("; "+p); if (b==-1) { b=dc.indexOf(p); if (b!=0) return null; } else b+=2; var e=document.cookie.indexOf(";", b); if (e==-1) e=dc.length; return unescape(dc.substring(b + p.length, e)); }
	function dC(n,p,d) { if (gC(n)) { document.cookie = n + "=" + ((p) ? "; path=" + p : "") + ((d) ? "; domain=" + d : "") + "; expires=Thu, 01-Jan-90 00:00:01 GMT"; } }
	function sC(n,v,e,p,d,s) { var c=n+"="+escape(v)+((e)?"; expires="+e.toGMTString():"")+((p)?"; path="+p:"")+((d)?"; domain="+d:"")+((s)?"; secure":"");document.cookie = c; }
	function owinp(u) { self.opener.location=u; }
	var oldb=0; if (navigator.appName=="Netscape" && parseFloat(navigator.appVersion) < 5) oldb = 1; else if (navigator.appVersion.indexOf("MSIE") != -1) { temp = navigator.appVersion.split("MSIE"); version = parseFloat(temp[1]); if (version < 5) oldb = 1; }


function cipp(){
		var i = document.per.itemsper.options[document.per.itemsper.selectedIndex].value;
		var ed = new Date();
		ed.setTime(ed.getTime() + 2*365*24*60*60*1000);
		sC('s_itemsper',i,ed,'/');
        window.location.reload( true );

}

// Inserted by Spawn New Window Action
 function sp_Open( sURL , sTitle , sParameters )
 {
 	var remote = window.open( '' , sTitle , sParameters );
 	remote.location.replace(sURL);
 	if (!remote.opener)
 		remote.opener = self;
 	if (window.focus)
 		remote.focus();
 	return remote;
 }
 
 
 AlienMessage = window.AlienMessage;
 if (!AlienMessage)
 	AlienMessage = null;
 	

function clearText(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}
 
function validy(form) {

  var phone_tag = document.getElementById('phone').value;
  var email_tag = document.getElementById('email').value;


     if (!phone_tag)
	{
	 alert("You need to type in your phone number");
	 document.getElementById('phone').focus();
     return false;
	}
	 if (!email_tag)
	{
	 alert("You need to type in your email address");
	 document.getElementById('email').focus();
     return false;
	}
return true;
}

function validn(form) {
  var name_tag = form.username.value;
  var pass_tag = form.pass.value;
  var passretype_tag = form.retypepassword.value;
  var phone_tag = form.phone.value;
  var email_tag = form.email.value;

 if (!name_tag)
	{
   alert("You need to type your username");
     form.username.focus();
     return false;
	}
	if (!pass_tag)
	{
	 alert("You need to type your password");
	 form.pass.focus();
	 return false;
	}
     if (!passretype_tag)
	{
	 alert("You need to re-type your password");
	 form.retypepassword.focus();
     return false;
	}
     if (!phone_tag)
	{
	 alert("You need to type in your phone number");
	 form.phone.focus();
     return false;
	}
	 if (!phone_tag)
	{
	 alert("You need to type your email address");
	 form.email_tag.focus();
     return false;
	}
return true;
}

function valid(form) {
  var name_tag = form.user.value;
  var pass_tag = form.pass.value;
  var security_tag = form.security_try.value;
	if (!name_tag)
	{
   alert("You need to type your username");
	 return false;
	}
	if (!pass_tag)
	{
	 alert("You need to type your password");
	 return false;
	}
     if (!security_tag)
	{
	 alert("You need to type the Security Code");
	 return false;
	}
return true;
}
function validu(form) {
  var name_tag = form.user.value;
  var pass_tag = form.pass.value;
  var phone_tag = form.phone.value;
	if (!name_tag)
	{
   alert("You need to type your username");
   form.user.focus();
	 return false;
	}
	if (!pass_tag)
	{
	 alert("You need to type your password");
	 form.pass.focus();
	 return false;
	}
     if (!phone_tag)
	{
	 alert("You need to type your phone number");
	 form.phone.focus();
	 return false;
	}
return true;
}





function upcheck(form,sname) {
	if(form.status.value) {
        pmbox=confirm('Because of Security Options set by '+sname+', your upload has been put on pending. After review it will be posted to the site.\n\n Thank you for your Patience.');
	if (pmbox==true) { // Output when OK is clicked
	    return true;
	} else {
	// Output when Cancel is clicked
	return false;
	}
	} else {
	 return true;
	}
}

// This code is from Dynamic Web Coding
// www.dyn-web.com

var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
// settings for tooltip
var tipWidth				= 130;
var offX						= 12;	// how far from mouse to show tip
var offY						= 12;
var tipFontFamily	= "Verdana, arial, helvetica, sans-serif";
var tipFontSize 		= "8pt";
var tipFontColor		= "#000000";
var tipBgColor			= "#d4b8d7";
var tipBorderColor	= "#000000";
var tipBorderWidth	= 1;
var tipBorderStyle	= "solid";
var tipPadding			= 4;
var tooltipOBJ;
function ShowTooltip(evt,fArg){

    var tooltipOBJ = (document.getElementById) ? document.getElementById('tt' + fArg) : eval("document.all['tt" + fArg + "']");
    if (tooltipOBJ != null) {
	//var tooltipLft = (document.body.offsetWIDTH?document.body.offsetWIDTH:document.body.style.pixelWIDTH) - (tooltipOBJ.offsetWIDTH?tooltipOBJ.offsetWIDTH:(tooltipOBJ.style.pixelWIDTH?tooltipOBJ.style.pixelWIDTH:300)) - 30;
    if (ns4) tooltipOBJ.width = tipWidth;
	else if (ns5) tooltipOBJ.style.width = tipWidth;
	else if (ie4||ie5) tooltipOBJ.style.pixelWidth = tipWidth;
	if (ie4||ie5||ns5) {	// ns4 would lose all this on rewrites
		tooltipOBJ.style.fontFamily = tipFontFamily;
		tooltipOBJ.style.fontSize = tipFontSize;
		tooltipOBJ.style.fontColor = tipFontColor;
		tooltipOBJ.style.backgroundColor = tipBgColor;
		tooltipOBJ.style.borderColor = tipBorderColor;
		tooltipOBJ.style.borderWidth = tipBorderWidth;
		tooltipOBJ.style.padding = tipPadding;
		tooltipOBJ.style.borderStyle = tipBorderStyle;
	}

    if (ie4||ie5) {
        tooltipOBJ.style.pixelLeft = evt.clientX + offX + document.body.scrollLeft;
		tooltipOBJ.style.pixelTop = evt.clientY + offY + document.body.scrollTop;
	} else if (ns5) {
        tooltipOBJ.style.left = evt.pageX + offX;
		tooltipOBJ.style.top = evt.pageY + offY;
	}
	//alert(tipWidth);
	tooltipOBJ.style.visibility = "visible";
    }
}

function HideTooltip(fArg)
{
    var tooltipOBJ = (document.getElementById) ? document.getElementById('tt' + fArg) : eval("document.all['tt" + fArg + "']");
    if (tooltipOBJ != null) {
	tooltipOBJ.style.visibility = "hidden";
    }
}

function cc_check(form) {
  var x_card_num_tag = form.x_card_num.value;
  var x_exp_date_tag = form.x_exp_date.value;
   var x_first_name_tag = form.x_first_name.value;
  var x_last_name_tag = form.x_last_name.value;
   var x_address_tag = form.x_address.value;
  var x_city_tag = form.x_city.value;
   var x_state_tag = form.x_state.value;
  var x_zip_tag = form.x_zip.value;
  var x_country_tag = form.x_country.value;
  var x_email_tag = form.x_email.value;

	if (!x_card_num_tag)
	{
   alert("You need to type the Credit Card number.");
	 return false;
	}
	if (!x_exp_date_tag)
	{
	 alert("You need to type the expiration.");
	 return false;
	}
     if (!x_first_name_tag)
	{
   alert("You need to type your name.");
	 return false;
	}
	if (!x_last_name_tag)
	{
   alert("You need to type your last name.");
	 return false;
	}
	if (!x_address_tag)
	{
   alert("You need to type your address.");
	 return false;
	}
	if (!x_city_tag)
	{
   alert("You need to type your city.");
	 return false;
	}
	if (!x_state_tag)
	{
   alert("You need to type your state.");
	 return false;
	}
	if (!x_zip_tag)
	{
   alert("You need to type your zipcode (postal code).");
	 return false;
	}
	if (!x_country_tag)
	{
   alert("You need to type in your country.");
	 return false;
	}
	if (!x_email_tag)
	{
   alert("You need to type your email address.");
	 return false;
	}
return true;
}

function del_lightprod(oForm, grpname) {
        var checked = 0, i = 0, chkArray;
	if (typeof oForm.elements[grpname].length == 'undefined')
        	chkArray = [oForm.elements[grpname]];
	else chkArray = oForm.elements[grpname];
        for (i; i < chkArray.length; i++)
		if (chkArray[i].checked)
			checked++;
	if (checked == 0) {
		alert('You need to check an image to be deleted first.');
		chkArray[0].focus();
        	return false;
	} else {
        var pmbox = confirm('Are you sure you want to delete the selected product' + ((checked > 1) ? 's' : '') + '?');
        if (pmbox==true) { // Output when OK is clicked
    	    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 del_lightbox(namebox,Path) {
        pmbox=confirm('Are you sure you want to delete your lightbox named '+namebox+' ? \n\n All Items will be deleted also');
    if (pmbox==true) { // Output when OK is clicked
             document.getElementById('progress').style.display = '';
             http.open("GET", Path+"/ajaxitem.php?do=del&name="+namebox, true);
             http.send(null);
             http.onreadystatechange = handleResponse;
    }

}
function add_lightbox(Path) {
        var namebox=prompt('What is the name of your new Lightbox?');    
    if ((namebox != ' ') && (namebox != '')) { // Output when OK is clicked
             document.getElementById('progress').style.display = '';
             http.open("GET", Path+"/ajaxitem.php?do=newname&name="+namebox, true);
             http.send(null);
             http.onreadystatechange = handleResponse;
	} else {
	    lightbox_notify('Your Lightbox name is empty.',Path);
	    
	}
}

function add_lightProd(ID,Path) {
    http.open("GET", Path+"/ajaxitem.php?do=light&prodid="+ID, true);
    http.send(null);
    http.onreadystatechange = handleResponse;

}

function mov_lightprod(oForm, grpname,Path) {
    var checked = 0, i = 0, chkArray;
	if (typeof oForm.elements[grpname].length == 'undefined') {
	chkArray = [oForm.elements[grpname]];
	} else { chkArray = oForm.elements[grpname];
        for (i; i < chkArray.length; i++) {
    		if (chkArray[i].checked) {
    			checked++;
    	    }
        }
	}
	if (checked == 0)
	{
		alert('You need to check an image to be moved first.');
 	    chkArray[0].focus();
     	return false;
	} else {
        var namebox=confirm('Are you sure you want to move the selected product' + ((checked > 1) ? 's' : '') + '?');
        // for submiting POST but need to figure out how to send array if multiple checkboxes are checked
        /*if ((namebox == true)) { // Output when OK is clicked
                 document.getElementById('progress').style.display = '';
                 var movevalue=encodeURIComponent(document.getElementById("move").value);
                 var to_boxvalue=encodeURIComponent(document.getElementById("to_box").value);
                 var parameters="move="+movevalue+"&to_box="+to_boxvalue+"delight="+chkArray[0];
                 http.open("POST", Path+"/ajaxitem.php", true);
                 http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                 http.send(parameters);
                 http.onreadystatechange = handleResponse;
    	} */
    }


}

function lightbox_notify(Notes,Path) {
	    alert(Notes);
        window.location=Path+"/lightbox.php/view";
}

function createRequestObject(){

    var req;
    
    if(window.XMLHttpRequest){
        //For Firefox, Safari, Opera
        req = new XMLHttpRequest();
    }
        else if(window.ActiveXObject){
        //For IE 5+
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else{
        //Error for an old browser
        alert('Your browser is not IE 5 or higher, or Firefox or Safari or Opera');
    }

    return req;
}

//Make the XMLHttpRequest Object
var http = createRequestObject();

/*
0 Uninitialized 
    The initial value.
1 Open
    The open() method has been successfully called.
2 Sent
    The UA successfully completed the request, but no data has yet been received.
3 Receiving
    Immediately before receiving the message body (if any). All HTTP headers have been received.
4 Loaded
*/
function handleResponse(){
    if(http.readyState == 4 && http.status == 200){
        var response = http.responseText;
        if(response){
            //document.getElementById("ajax_res").innerHTML = response;
            eval(response);
        }
    } else {
        //alert(http.readyState)
    }
}

function submitForm(color){
	var search_url="http://www.stockedphotos.com/search.php";
    var cp_color=color;
	var similarcolors;
 if(document.frmDetail.similarcolors.checked)
		similarcolors="1";
 else
  similarcolors="";
	document.frmDetail.action= search_url+"?frmAction=colorsearch&colorpicker=True&cp_color="+color+"&similarcolors="+similarcolors;
	document.frmDetail.submit();
}

function subcategory(){
	document.advsearch.frmAction.value="subcategory";
	document.advsearch.submit();
}
function resetValues(){
	document.advsearch.keywords.value="";
	document.advsearch.excludes.value="";
	document.advsearch.cp_color.value="";
}
function submitSearch(){
	document.advsearch.frmAction.value="search";
	document.advsearch.submit();
}
/*function TestCKBox(fObj,theDiv){
	var small_image="<?=SITE_URL?>/images/small_colorchart.gif";
	var el = document.getElementById(theDiv);
	if (fObj.checked == true){
		el.style.display = "block";
	} else {
		el.style.display = "none";
		document.advsearch.cp_color.value="";
		document.advsearch.small_color.style.backgroundColor="";
		document.advsearch.small_color.style.backgroundImage = 'url(' + small_image + ')';
	}
}*/
function TestCKBox(fObj,theDiv){
	var small_image="http://www.stockedphotos.com/images/small_colorchart.gif";
	var el = document.getElementById(theDiv);
	if (fObj.checked == true){
		el.style.display = "block";
	} else {
		el.style.display = "none";
		document.advsearch.cp_color.value="";
		document.getElementById('small_color').style.backgroundColor="";
		//document.all.small_color.style.backgroundImage="{SITE_URL}/images/small_colorchart.gif";			
		document.getElementById('small_color').style.backgroundImage = 'url(' + small_image + ')';
	}
}

function selectcolor(color){
	document.advsearch.cp_color.value="#"+color;
  	document.getElementById("small_color_img").style.backgroundColor="#"+color;
  	document.getElementById("small_color_img").style.backgroundImage='';
}

function showcolor(c){
  	document.getElementById("small_color_img").style.backgroundColor="#"+c;
  	document.getElementById("small_color_img").style.backgroundImage='';
	var con = cp_calc_contrast(c);
	document.getElementById("cp_contrast").style.backgroundColor = con;
}

function colorDiv(theDiv){
	var small_image="http://www.stockedphotos.com/images/small_colorchart.gif";
	var el = document.getElementById(theDiv);
	if(el.style.display == "block"){
		el.style.display = "none";
		document.cp_color.value="";
		document.getElementById("small_color_img").style.backgroundColor="";
		document.getElementById("small_color_img").style.backgroundImage='url(' + small_image + ')';
	} else {
		el.style.display = "block";
	}
}

function submitDetail(id){
	//var url="http://www.stockedphotos.com/members_test.php/info/mp_/"+id;
	var url="http://www.stockedphotos.com/info.php/mp_/"+id;
	document.frmSearch.action=url;
	document.frmSearch.submit();
}
function rowsshown(){
	var i = document.per.itemsper.options[document.per.itemsper.selectedIndex].value;
	document.per.slimit.value=i;
	document.per.submit();
}


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 toggle_collapse(objid,url)
{

	obj = document.getElementById(objid);
	img = document.getElementById("collapseimg_" + objid);
    if (obj.style.display == "none")
	{
    	var itemcol = '';
        obj.style.display = "";
		save_collapsed(objid,itemcol,true);
		if(img){
		    img.src = url+'/icon-minus.gif';
		}
	}
	else
	{
    	var itemcol = 'display:none';
        obj.style.display = "none";
		save_collapsed(objid,itemcol,false);
		if(img){
		    img.src = url+'/icon-plus.gif';
		}
	}
	return false;
}
function save_collapsed(objid, value,isset)
{
	if (!isset){
	   document.cookie = "link_collapse" + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT" +  "; path=/";
	} else {
       expires = new Date();
	   expires.setTime(expires.getTime() + (1000 * 86400 * 365));
       document.cookie = "link_collapse" + "=" + escape(objid) + "; expires=" + expires.toGMTString() +  "; path=/";

    }

}
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;
}
