function saveFlyer(title, url){
     if (window.sidebar) {
      window.sidebar.addPanel(title, url,"");
     } else if( window.external ) {
      window.external.AddFavorite( url, title); 
     } else if(window.opera && window.print) {
       return true; 
     }
 }
 
function flagFlyer(){
 var URL = window.location.href;
 var reqURL;
 if (URL.indexOf("localhost:8080") != -1){
	var flyerId = URL.replace("http://localhost:8080/pca/site/","");
	flyerId = flyerId.replace("/index.html","");
	reqURL = "http://localhost:8080/main/action?action=Flag&prodInstId="+encodeURIComponent(flyerId);
 }else{
	var temp = URL.split(".");
	var hostName = temp[1];
	var acctName = temp[0].replace("http://","");
	var siteDir = temp[2].replace("/index","");
	siteDir = siteDir.replace("com/","");
	reqURL = "http://"+acctName+"."+hostName+".com/main/action?action=Flag&acctName="+encodeURIComponent(acctName)+"&siteDir="+encodeURIComponent(siteDir);
 }
 var ajax = new AJAXInteraction(reqURL, validateCallback); 
 ajax.doGet(); 
 document.getElementById("redFlag").style.display="inline";
 document.getElementById("flag").style.display="none";
}

function setCookie(path, domain, secure ) {
	// set time, it's in milliseconds
	var name = "referrerURL"; //name of the cookie
	var today = new Date();
	today.setTime( today.getTime() );
	var value = document.referrer; //value of the cookie
	var expires = 5 * 1000 * 60; // expiry time set to minutes
	var expires_date = new Date( today.getTime() + (expires) );
	document.cookie = name + "=" +escape( value ) +
	( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
	( ( path ) ? ";path=" + path : "" ) + 
	( ( domain ) ? ";domain=" + domain : "" ) +
	( ( secure ) ? ";secure" : "" );
}

function AJAXInteraction(url, callback) {
	var req = init();
	req.onreadystatechange = processRequest;
	function init() {
	  if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	  } else if (window.ActiveXObject) {
		return new ActiveXObject("Microsoft.XMLHTTP");
	  }
	}    
	function processRequest () {
	  // readyState of 4 signifies request is complete
	  if (req.readyState == 4) {
	// status of 200 signifies sucessful HTTP call
		if (req.status == 200) {
		  if (callback) callback(req.responseXML);
		}
	  }
	}
	this.doGet = function() {
	  // make a HTTP GET request to the URL asynchronously
	  req.open("GET", url, true);
	  req.send(null);
	}
}

function getParameter ( parameterName ) {
	queryString = window.top.location.search.substring(1);
	// Add "=" to the parameter name (i.e. parameterName=value)
	var parameterName = parameterName + "=";
	if ( queryString.length > 0 ) {
		// Find the beginning of the string
		begin = queryString.indexOf ( parameterName );
		// If the parameter name is not found, skip it, otherwise return the value
		if ( begin != -1 ) {
			// Add the length (integer) to the beginning
			begin += parameterName.length;
			// Multiple parameters are separated by the "&" sign
			end = queryString.indexOf ( "&" , begin );
			if ( end == -1 ) {
				end = queryString.length
			}
			// Return the string
			return unescape ( queryString.substring ( begin, end ) );
		}
		// Return "null" if no parameter has been found
		return "null";
	}
}

function validateCallback(responseXML){}
