function mhp(page){
	createCookie('hp', page, 30);
	document.getElementById("setHomePage").innerHTML = "This is now your home page!";
	setTimeout("Effect.Fade('setHomePage')", 4000);
	
}

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 null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

/* Client-side access to querystring name=value pairs
	Version 1.2.4
	30 March 2008
	Adam Vandenberg
	http://adamv.com/dev/javascript/querystring
*/
function Querystring(qs) { // optionally pass a querystring to parse
	this.params = {};
	this.get=Querystring_get;
	
	if (qs == null);
		qs=location.search.substring(1,location.search.length);

	if (qs.length == 0) 
		return;

// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
	
// split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var pair = args[i].split('=');
		var name = unescape(pair[0]);
		
		var value = (pair.length==2)
			? unescape(pair[1])
			: name;
		
		this.params[name] = value;
	}
}

function Querystring_get(key, default_) {
	var value=this.params[key];
	return (value!=null) ? value : default_;
}
//start();

function fold2(theid, iconid) {
  	var theid=document.getElementById(theid);
  	var iconid=document.getElementById(iconid);
  	theid.style.display=(theid.style.display=="none") ? "block" : "none";
 	iconid.src=(theid.style.display=="none") ? "img/arrow-right.jpg" : "img/arrow-down.jpg";
  	theid.style.width='100%';
}

function validateFormMonetizeApp(frm){
	if(frm.applicationName.value.length == 0){
		alert("Please enter an Application Name in the field provided.");
		frm.applicationName.focus();
		return false;
	}
        sel = document.getElementById(txtSocialNetwork); 
        if(sel.value == "website") {
                return true;
	} else if(frm.applicationID.value.length == 0){
		alert("Please enter an Application ID in the field provided.");
		frm.applicationID.focus();
		return false;
	}
	return true;
}

function validateFormAdvertiseApp(frm){
	if(frm.applicationName.value.length == 0){
		alert("Please enter an Application Name in the field provided.");
		frm.applicationName.focus();
		return false;
	}
	if(frm.applicationID.value.length == 0){
		alert("Please enter an Application ID in the field provided.");
		frm.applicationID.focus();
		return false;
	}
	return true;
}

function validateFormAdvertise(frm){
	return true;
}

function dismissMessage(div_id){
	new Ajax.Request('xhr_message.php', {
	  	method: 'get',
		onSuccess: function(transport){
      		var response = transport.responseText || "no response text";
      		//alert("Success! \n\n" + response);
    	},
    	onFailure: function(){ 
			//alert('Something went wrong...');
		},
	  	parameters: {mid: div_id}
	});
	Effect.Fade(div_id); return false;

}

  function changeCostType() {
   var applicationCostType = document.getElementById('campaignType');
   var cur_costType;
   for(var i=0;i<applicationCostType.options.length;i++) {
       if(applicationCostType.options[i].selected) {
         cur_costType=applicationCostType.options[i].value;
     }
   }
   if(cur_costType == "cpm") {
   	var divName = document.getElementById(cur_costType+'_label');
   	document.getElementById("cpc_label").style.visibility = "hidden";
   	document.getElementById("cpi_label").style.visibility = "hidden";
   	divName.style.visibility="visible";
   } else if(cur_costType == "cpc") {
   	var divName = document.getElementById(cur_costType+'_label');   
   	document.getElementById("cpm_label").style.visibility = "hidden";   
   	document.getElementById("cpi_label").style.visibility = "hidden";
   	divName.style.visibility="visible";   
  } if(cur_costType == "cpi") {
   	var divName = document.getElementById(cur_costType+'_label');   
   	document.getElementById("cpc_label").style.visibility = "hidden";   
   	document.getElementById("cpm_label").style.visibility = "hidden";
   	divName.style.visibility="visible";   
  }
   
  
  }

