function CheckPromoCode()
{
	
	
	/*var yr=document.getElementById("yearly_subscription");
	var month=document.getElementById("monthly_subscription");
	
	var the_frm=document.getElementById("subscription_frm");
	
	/*if(yr.checked)
	{
		var price=(parseFloat(the_frm.base_price.value)-(parseFloat(the_frm.base_price.value)*parseFloat(the_frm.year_discount.value)))*12;
	
		the_frm.a3.value=Math.round(price*100)/100;
		the_frm.p3.value="1";
		the_frm.t3.value="Y";
	}
	else
	if(month.checked)
	{
		the_frm.a3.value=parseFloat(the_frm.base_price.value);
		the_frm.p3.value="1";
		the_frm.t3.value="M";
	}*/
	
	the_frm.submit();
}

function ChangeNumResults()
{
	
	var pglim=document.getElementById("c_pglim");
	var img_type = document.getElementById("c_img_type");
	var keywords=document.getElementById("c_keywords");
	var category=document.getElementById("c_category");
	var subcategory=document.getElementById("c_subcategory");
	var price_band=document.getElementById("c_price_band");
	var pgst=document.getElementById("c_pgst");
	
	location.href='search.php?image_type=' + img_type.value + '&keywords=' + keywords.value + '&view=all&category=' + category.value + '&subcategory=' + subcategory.value + '&price_band=' + price_band.value + '&pglim=' + pglim.value + '&pgst=' + pgst.value;

}

function FinishedRegistering(){
	location.href='index.php';	
}

function UpdateSubscriptionData()
{
	var yr=document.getElementById("yearly_subscription");
	var month=document.getElementById("monthly_subscription");
	
	var the_frm=document.getElementById("subscription_frm");
	
	/*if(yr.checked)
	{
		var price=(parseFloat(the_frm.base_price.value)-(parseFloat(the_frm.base_price.value)*parseFloat(the_frm.year_discount.value)))*12;
	
		the_frm.a3.value=Math.round(price*100)/100;
		the_frm.p3.value="1";
		the_frm.t3.value="Y";
	}
	else
	if(month.checked)
	{
		the_frm.a3.value=parseFloat(the_frm.base_price.value);
		the_frm.p3.value="1";
		the_frm.t3.value="M";
	}*/
	
	the_frm.submit();
}

function UpdateUpgradeSubscriptionData()
{
	//var yr=document.getElementById("yearly_subscription");
	//var month=document.getElementById("monthly_subscription");
	
	var bronze=document.getElementById("bronze_subscription");
	var silver=document.getElementById("silver_subscription");
	var gold=document.getElementById("gold_subscription");
	
	var the_frm=document.getElementById("upgrade_subscription_frm");
	
	if(bronze.checked)
	{
		the_frm.a3.value=parseFloat(23.50);
		the_frm.p3.value="1";
		the_frm.t3.value="M";
		the_frm.item_name.value="Subscription to www.3sixo.net (Full Subscription - monthly payment, no minimum contract)";
	}
	else
	if(silver.checked)
	{
		the_frm.a3.value=parseFloat(11.75);
		the_frm.p3.value="12";
		the_frm.t3.value="M";
		the_frm.item_name.value="Subscription to www.3sixo.net (Full Subscription - monthly payment, minimum 12 month contract)";
	}
	else
	if(gold.checked)
	{
		the_frm.a3.value=parseFloat(141.00);
		the_frm.p3.value="1";
		the_frm.t3.value="Y";
		the_frm.item_name.value="Subscription to www.3sixo.net (Full Subscription - annual payment)";
	
	}
	
	//alert (the_frm.item_name.value);
	the_frm.submit();
}

function SubmitSearch(){
	
	var the_frm=document.getElementById("search_frm");
	//var keywords=document.getElementById("keywords");
	var keywords=the_frm.keywords;
	
	//alert (keywords.value);
	/*
	if(keywords.value.length==0)
		location.href='bunkspeed_categories.php';
		//the_frm.submit();
	else 
		if(keywords.value=="Search")
			location.href='bunkspeed_categories.php';
			//the_frm.submit();
		else 
			the_frm.submit();*/
	the_frm.submit();
		
}

function SubmitAdvancedSearch(){
	
	var the_frm=document.getElementById("advanced_search_frm");
	//var keywords=document.getElementById("keywords");
	var keywords=the_frm.keywords;
	//alert (keywords.value);
	
	if(keywords.value.length==0)
		location.href='3sixo_categories.php';
		//the_frm.submit();
	else 
		if(keywords.value=="Search")
			location.href='3sixo_categories.php';
			//the_frm.submit();
		else 
			the_frm.submit();
		
}

function RemoveConditionalValue(obj,txt)
{

	if(obj.value==txt)
		obj.value="";
}

function LogoutUser()
{
	var frm=document.getElementById("logout_frm");
	frm.submit();
}

function ClickForgotPass()
{
	
	var frm=document.getElementById("password_frm");
	
	var usr_in = document.getElementById("in_username");
	
	if(usr_in.value.length==0)
		alert("To retrieve your password, please enter your username then click the 'Send' button");
	else
		//location.href = "retrieve.php?user="+usr_in.value;*/
		frm.submit();

}

function ChangeCategory(selector)
{
	
	var frm = document.getElementById("search_frm");

	frm.submit();
}

function SubmitFreelance(){
	
	var frm = document.getElementById("freelancepost");
	frm.submit();
}

function SubmitGallery(){
	
	var frm = document.getElementById("gallerysubmissionform");
	frm.submit();
}

function ConfirmWetaImageAdditionByID(imageid,thumburl,numcredits){    
    var t="<div class='warning'>";
    t+="    <div class='modal_warning_style' style='background-image: url("+thumburl+");'>Are you sure you want to add the selected image(s) to your account?<br/>\
    <br/>This will use up one of your image credits, and it cannot be undone.<br/><br/><img style='cursor:pointer; cursor:hand' onclick='Modalbox.hide({afterHide: function() { ConfirmWetaImageAdditionByID_callMyFunction("+imageid+"); } });' src='images/agree.png'><br/></div>";
    t+="</div>";
    
    Modalbox.show(t, {title: "Add item to downloads?", width: 330, height:230});
}


function ConfirmWetaImageAdditionByID_callMyFunction(imageid) {
    document.getElementById("ConfirmWetaImageAddition").ImageID.value = imageid;
    document.getElementById("ConfirmWetaImageAddition").submit();
}

function ConfirmImageAddition(){
	if(confirm("Are you sure you want to add the selected image(s) to your account?  \r\nThis will use up the appropriate number of your images, and it cannot be undone.  ")){
		document.getElementById("ConfirmImageAddition").submit();
	}
}
function ConfirmImageAdditionByID_callMyFunction(imageid) {
    document.getElementById("ConfirmImageAddition").ImageID.value = imageid;
    document.getElementById("ConfirmImageAddition").submit();
}

function ConfirmImageAdditionByID(imageid,thumburl,numcredits)
{    
    var t="<div class='warning'>";
    t+="    <div class='modal_warning_style' style='background-image: url("+thumburl+");'>Are you sure you want to add the selected image(s) to your account?<br/>\
    <br/>This will use up <b>" + numcredits + "</b> credits, and it cannot be undone.<br/><br/><img style='cursor:pointer; cursor:hand' onclick='Modalbox.hide({afterHide: function() { ConfirmImageAdditionByID_callMyFunction("+imageid+"); } });' src='images/agree.png'><br/></div>";
    t+="</div>";
    
    Modalbox.show(t, {title: "Add item to downloads?", width: 330, height:230});
}

function YouveAlreadyBoughtThat(imageid,thumburl,numcredits)
{    
    var t="<div class='warning'>";
    t+="    <div class='modal_warning_style' style='background-image: url("+thumburl+");'>You have already purchased this image, and cannot add it to your account again.<br/>\
    <br/>Go to the downloads section of your account panel to download this image.<br/><br/><img style='cursor:pointer; cursor:hand' onclick='Modalbox.hide();' src='images/ok.png'><br/></div>";
    t+="</div>";
    
    Modalbox.show(t, {title: "You already have this image!", width: 330, height:230});
}

function ToggleLightbox(whichpanel){
	
	myitem = document.getElementById("bottom_fixed");
	
	thisitemwhat = document.getElementById("main_container_fake");
	
	
	//alert (thisitemwhat.style.height)
	
	//alert (myitem.style.height);
	if(whichpanel=='lightbox'){
		myheight = '158px'
		mypadding = '0px 0px 150px 0px'
	} else if(whichpanel=='downloads'){
		myheight = '158px'
		mypadding = '0px 0px 150px 0px'
	} else {
		myheight = '340px'
		mypadding = '0px 0px 350px 0px'
	}
	
	if(myitem.style.height == '20px'){
		//alert ("closed");
		myitem.style.height = myheight
		myitem.style.overflow = 'auto';
		//set padding to nothing
        if (thisitemwhat) {
            thisitemwhat.style.padding = mypadding
        }
        setMaximized();
		
	} else if(myitem.style.height == '1587px'){
		//alert ("open");
		myitem.style.height = '20px'
		myitem.style.overflow = 'hidden';
		//set padding to nothing
        if (thisitemwhat) {
            thisitemwhat.style.padding = '0 0 70px 0'
        }
        setMinimized();
		
	} else if(myitem.style.height == '340px'){
		//alert ("open");
		myitem.style.height = '20px'
		myitem.style.overflow = 'hidden';
		//set padding to nothing
        if (thisitemwhat) {
    		thisitemwhat.style.padding = '0 0 70px 0'
        }
        setMinimized();
	} else {
		//alert ("cannot find");
		myitem.style.height = '20px'
		myitem.style.overflow = 'hidden';
		//set padding to nothing
        if (thisitemwhat) {
            thisitemwhat.style.padding = '0 0 50px 0'
        }
        setMinimized();
	}
	

}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    }
  }
return "";
}

function setMinimized() {
    document.cookie = 'state1=min; expires=Thu, 2 Aug 2099 20:47:11 UTC; path=/'
}

function setMaximized() {
    document.cookie = 'state1=max; expires=Thu, 2 Aug 2099 20:47:11 UTC; path=/'
}

function DisplayInfoPage(mytitle,whichpage)
{    

	var LegalText = "This is the text that i want to include";
	
	var scruffyIFrame = "<iframe src ='" + whichpage + "' width='100%' height='390px'><p>Your browser does not support iframes.</p></iframe>";
	
    var t="<div class='warning'>";
    t+= scruffyIFrame + "<br/><br/><img style='cursor:pointer; cursor:hand' onclick='Modalbox.hide();' src='images/agree.png'><br/></div>";
    t+="</div>";
    
    Modalbox.show(t, {title: mytitle, width: 800, height:530});
}