if (window.addEventListener) window.addEventListener("load",function(){updateHREF();},false);
else if (window.attachEvent) window.attachEvent("onload",function(){updateHREF();});


function GetParam(name){ /*Returns values from location urls and assigns to reference variable*/
var start=location.search.indexOf("?"+name+"=");
if (start<0) start=location.search.indexOf("&"+name+"=");
if (start<0) return '';
start += name.length+2;
var end=location.search.indexOf("&",start)-1;
if (end<0) end=location.search.length;
var result=location.search.substring(start,end);
var result='';
for(var i=start;i<=end;i++) {
	var c=location.search.charAt(i);
	result=result+(c=='+'?' ':c);}
return unescape(result);
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return '';
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function updateHREF(){
c_status=readCookie('c_status');
c_serial=readCookie('c_serial');
c_ref=readCookie('c_ref');

  for (var l_linkNo = 0; l_linkNo < document.links.length; l_linkNo++) {
      var t_lowerHREF = document.links[l_linkNo].href.toLowerCase();
      if (t_lowerHREF.indexOf("accounts.comodo.com/cfp/management/signup")!=-1){
		//document.links[l_linkNo].href=t_lowerHREF+"?status="+c_status+"&ref="+c_ref+"&serial="+c_serial;
		if(document.links[l_linkNo].id == "orderlink1")
		{
			document.links[l_linkNo].href=t_lowerHREF+"?status=256&ref="+c_ref+"&serial="+c_serial;
		}
		else if(document.links[l_linkNo].id == "orderlink2")
		{
			document.links[l_linkNo].href=t_lowerHREF+"?status=-256&ref="+c_ref+"&serial="+c_serial;
		}
		else
		{
			document.links[l_linkNo].href=t_lowerHREF+"?status="+c_status+"&ref="+c_ref+"&serial="+c_serial;
		}
      }
  }
}


function show_fastfacts(where){




var facts=new Array();
var start=1;

facts[0]="Comodo secures and authenticates online transactions and communications for over 10,000,000 businesses and consumers.";
facts[1]="A fully accredited AICPA/CICA WebTrust compliant Certification Authority – the highest globally-recognized standard.";
facts[2]="Comodo controls more than one-quarter of the worldwide<br>digital certificate market.";
facts[3]="Comodo customers include: 7 of the top 10 Fortune 1000, 5 of the top 7 U.S. universities, the top 2 global software providers, and 2 of the top 20 financial institution.";




setInterval (function(){if (start>3){start=0}document.getElementById('fast_facts').innerHTML = '<h4>'+facts[(start++)]+'</h4>'}, 3000 );



}

function secure_login()
{
	obj = document.getElementById("login_box");
	
	if(obj)
	{
		if(obj.style.display == "none" || obj.style.display == "")
		{
			obj.style.visibility = "visible";
			obj.style.display = "block";
			obj.style.top = "5px";
			obj.style.left = "300px";
		}

		if(document.getElementsByName("username")[0])
		{
			document.getElementsByName("username")[0].focus();
		}		
	}	
}

function secure_login_close(){
	obj = document.getElementById("login_box");
	
	if(obj)
	{
		obj.style.display = "none";
	}
}


activateMenu = function(nav) {
    /* currentStyle restricts the Javascript to IE only */
	if (document.all && document.getElementById(nav).currentStyle) {  
        var navroot = document.getElementById(nav);
        
        /* Get all the list items within the menu */
        var lis=navroot.getElementsByTagName("LI");  
        for (i=0; i<lis.length; i++) {
        
           /* If the LI has another menu level */
            if(lis[i].lastChild.tagName=="UL"){
            
                /* assign the function to the LI */
             	lis[i].onmouseover=function() {	
                	this.className="mbghover";
					//alert(this.className);
					/*this.style.backgroundRepeat="repeat-x";this.className="mbghover";*/
                   /* display the inner menu */
                   this.lastChild.style.display="block";
                }
                lis[i].onmouseout=function() {                       
                   this.lastChild.style.display="none";
				   //this.style.background="";
				   this.className="mbghover";
                }
            }
        }
    }
}
var bodyheight;
	function detect_height()
	{
	
	if( typeof( window.innerWidth ) == 'number' ) 
	{
	//Non-IE
		bodywidth = window.innerWidth;
		bodyheight = window.innerHeight;
		
	} 
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		//IE 6+ in 'standards compliant mode'
		bodywidth = document.documentElement.clientWidth;
		bodyheight = document.documentElement.clientHeight;
	} 
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		//IE 4 compatible
		bodywidth = document.body.clientWidth;
		bodyheight = document.body.clientHeight;
	}	
	 ret = ((parseInt(bodyheight)) - 171); 
	 return ret;
	}
	
	function set_height(obj)
	{
		target_obj = document.getElementById(obj);
		ht = detect_height();
		target_obj.style.height = ht + "px";
	}
window.onload= function(){
    /* pass the function the id of the top level UL */
    /* remove one, when only using one menu */
    activateMenu('nav');
}

function drawMenu(){
	var img_src = '/style/images/'
	document.write ("<ul id=\"nav\">");	
	document.write ("<li><a class=\"menufirst\" style=\"padding-left:10px; \" href=\"/reseller/overview.html\" id=\"top_menu_reseller\">Reseller Program</a>");
	document.write ("<ul style=\"margin-left:5px;\">");
	document.write ("<li><a href=\"/reseller/overview.html\">Reseller Program Overview</a></li>");
	document.write ("<li><a href=\"/reseller/how_it_works.html\">How the Program Works</a></li>");
	document.write ("<li><a href=\"/reseller/powered_ssl.html\">Powered SSL</a></li>");
	document.write ("<li><a href=\"/reseller/pricingcalculator.html\">Reseller Pricing Calculator</a></li>");
	document.write ("<li><a href=\"https://secure.instantssl.com/products/frontpage?area=reseller&ap=instantssl\">Sign up Now</a></li>");
	document.write ("<li style=\"height:5px;list-image-style:none;padding-bottom:0px;margin-bottom:0px;list-style-type:none;font-size:0px;\"><img src=\"" + img_src + "menu_bottom.gif\" style=\"right:0px left:0px;position:absolute\" /></li>");
	document.write ("</ul>");
	document.write ("</li>")
	
	document.write ("<li><a class=\"dropmenu\" href=\"/webhost/overview.html\" id=\"top_menu_web_host\">Web Host Program</a>");
	document.write ("<ul>");
	document.write ("<li><a href=\"/webhost/overview.html\">Web Host Overview</a></li>");
	document.write ("<li><a href=\"/webhost/how_it_works.html\">How the Program Works</a></li>");
	document.write ("<li><a href=\"/webhost/powered_ssl.html\">Powered SSL</a></li>");
	document.write ("<li><a href=\"/webhost/pricingcalculator.html\">Web Host Pricing Calculator</a></li>");
	document.write ("<li><a href=\"https://secure.instantssl.com/products/frontpage?area=webhost&ap=instantssl\">Sign up Now</a></li>");
	document.write ("<li style=\"height:5px;list-image-style:none;padding-bottom:0px;margin-bottom:0px;list-style-type:none;font-size:0px;\"><img src=\"" + img_src + "menu_bottom.gif\" style=\"right:0px left:0px;position:absolute\" /></li>");
	document.write ("</ul>");
	document.write ("</li>")



	document.write ("<li><a class=\"dropmenu\" 	style=\"width:130px;\"	href=\"/products.html\" id=\"top_menu_enterprise\">Latest Products</a>");
	document.write ("</li>")

	
	document.write ("<li><a class=\"menu3\" href=\"/affiliate/overview.html\" id=\"top_menu_affiliate\">Affiliate Program</a>");
	document.write ("</li>");	

	document.write ("<li><a class=\"dropmenu\" href=\"/partner/partnerdoc.html\" id=\"top_menu_web_host\">Partner Resource Center</a>");
	document.write ("<ul style=\"margon-left:5px;\" id=\"last_nav\">");
	document.write ("<li><a href=\"/partner/partnerdoc.html\">Partner Documentation</a></li>");
	document.write ("<li><a href=\"/partner/trustlogo.html\">TrustLogos</a></li>");
	document.write ("<li><a href=\"/partner/rootkey.html\">Root Keys</a></li>");
	document.write ("<li><a href=\"/partner/evssl.html\">Comodo EV SSL</a></li>");
	document.write ("<li style=\"height:5px;list-image-style:none;padding-bottom:0px;margin-bottom:0px;list-style-type:none;font-size:0px;\"><img src=\"" + img_src + "menu_bottom_small.gif\" style=\"right:0px left:0px;position:absolute\" /></li>");
	document.write ("</ul>");
	document.write ("</li>")

	document.write ("</li>");
	document.write ("</ul>");
}

/* TAB section */

var content_suffix = "_content";

//Show hide individual sections onmouseover
function show_hide(opt, tabs_array)
{
	if(document.getElementById(opt))
	{
		hide_all(tabs_array);
		document.getElementById(opt).style.backgroundImage="url(" + images_path + opt + "_on.gif)";
		document.getElementById(opt).style.backgroundRepeat="no-repeat";
		document.getElementById(opt + content_suffix).style.display="block";
	}
}

//Hide all sections

function hide_all(tabs_array)
{
	i=0;
	flag = true;
	tabs_length = tabs_array.length;
	while(i < tabs_length)
	{
		if(document.getElementById(tabs_array[i]))
		{
			document.getElementById(tabs_array[i] + content_suffix).style.display="none";
			document.getElementById(tabs_array[i]).style.backgroundImage="url(" + images_path + tabs_array[i] + "_off.gif)";
			document.getElementById(tabs_array[i]).style.backgroundRepeat="no-repeat";
		}
		i++;
	}
}



function urlGO(id){
	
	var selObj = document.getElementById(id);
	var selIndex = selObj.links.selectedIndex;
	var selUrl=selObj.links.options[selIndex].value;
	location.href = selUrl;
}

function popUp(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=420,height=400,left = 302,top = 184');");
}
function element_focus(target, default_text, type)
{
	focus_color = '#1F5378';
	default_color = '#0166FF';
	if(type == 1)
	{
		if(target.value == '' || target.value == default_text)
		target.value = '';
		target.style.color = focus_color;
	}
	else if(type == 2)
	{
		if(target.value == '')
		{
			target.style.color = default_color;
			target.value = default_text;
		}
	}	
}



    function validate() {

    var theMessage = "Please complete the following: \n-----------------------------------\n";
    var noErrors = theMessage


	if (document.partner_contact.last_name.value=="") {
    theMessage = theMessage + "\n Name is required";
    }
	if (document.partner_contact.company.value=="") {
    theMessage = theMessage + "\n Company is required";
    }

	if (document.partner_contact.phone.value=="") {
    theMessage = theMessage + "\n Phone is required";
    }

	if (document.partner_contact.URL.value=="") {
    theMessage = theMessage + "\n Website is required";
    }

	if(document.partner_contact.country.selectedIndex==0){
    theMessage = theMessage + "\n Country is required";
	}


    if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.partner_contact.email.value)){
    theMessage = theMessage + "\n A valid e-mail address is required";
	}

    if (theMessage == noErrors) {
	alert("Thank you for submitting your information.\nA Partner Account Manager will contact you shortly.");
    return true;

    } else {


    alert(theMessage);
    return false;
    }
    }

