function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
function openNewScrolledWindow(target, sizeX, sizeY) {
	LeftPosition = (screen.width) ? (screen.width-sizeX)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-sizeY)/2 : 0;
	window.open(target,'_blank','menubar=false,scrollbars=yes,resizable=yes,top='+TopPosition+',left='+LeftPosition+',width='+sizeX+',height='+sizeY);
}
function openNewWindow(target, sizeX, sizeY) {
	LeftPosition = (screen.width) ? (screen.width-sizeX)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-sizeY)/2 : 0;
	window.open(target,'_blank','toolbar=no,menubar=no,scrollbars=no,resizable=yes,top='+TopPosition+',left='+LeftPosition+',width='+sizeX+',height='+sizeY);
}	
function reloadWindow(){
	window.opener.location.reload();
}
function confirmSubmission(msg){
	if (confirm(msg) == true)
		return true;
	else
		return false;
}
function getCurrentYear(){
	var d = new Date();
	return(d.getFullYear());
}
function getYearsEstablished(){
	return('1986');
}
function getYearsExperience(){
	//Set the two dates
	var startingdate=new Date(1981, 1, 1) // Founded: February 1980 but we'll use February, 1981 in calculation (Month is 0-11 in JavaScript)
	var today=new Date()
	
	//Get 1 day in milliseconds
	var one_day=1000*60*60*24
	var one_year=one_day*365
	
	//Calculate difference btw the two dates, and convert to days
	var year_exp = Math.ceil((today.getTime()-startingdate.getTime())/(one_year))
	
	return year_exp;
}
function getURL(strURL,isSSL) {
	var strProtocol = document.location.protocol;//IE "http" NN "http:"
	var strRight = "";
	var strFullURL = "";
	var strCurrentURL = document.location.hostname;
	var iLen = strCurrentURL.length;
	
	if (strProtocol == "http")	//IE "http"
		strProtocol = "http:";
	else if (strProtocol == "https")	//IE "https"
		strProtocol = "https:";
	
	if (iLen >= 3)
		strRight = strCurrentURL.substring(iLen, iLen - 4); //check if prod box --> ".com"

	//alert(strProtocol += "//www.creatingfamilies.com");
	
	//if some page on Prod need https
	if (isSSL == "true"){ 
		if (strRight == ".com")
		strProtocol = "https:";
	}
	if (isSSL == "false"){ 
		if (strRight == ".com")
		strProtocol = "http:";
	}
	
	if (strRight == ".com")
		strProtocol += "//www.creatingfamilies.com";
	else
		strProtocol = "..";	//test box
	
	strFullURL = strProtocol + strURL;
	
	document.location.href = strFullURL;
	
	return true;
}
function fullScreen(theURL) {
    window.open(theURL, '', 'fullscreen=yes, scrollbars=auto'); 
}
function getQueryString(sParamName) {
    if (location.search) {
        var vals = location.search.substring(1).split("&");
        var request = new Array();

        for (var i in vals) {
            vals[i] = vals[i].replace(/\+/g, " ").split("=");
            request[unescape(vals[i][0])] = unescape(vals[i][1]);
        }
    }
    var s = request[sParamName]; //i.e. request["ID"]
    
    return s;
}
function getVideoScript(strURL) {    
        
    var s = "";
    
    s += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='320' height='274' align='middle' ID='Shockwaveflash1' VIEWASTEXT>"
	s += "<param name='allowScriptAccess' value='sameDomain' />"
	s += "<param name='movie' value='http://66.132.232.43/creatingfamiliesvideo/VideoPlayer.swf' />"
	s += "<param name='FlashVars' value='flvURL=" + strURL + "&ControlPanelColor=0xffffff&buttonColor=0x383838&ControlPanelPosition=0&showControlPanel=1&ShowtimeColor=0xffffff&bAutoPlay=1&bAutoRepeat=0&BufferTime=5&tmeColor=0x800000&loaColor=0x2a2a2a&GroundColor=0x2a2a2a&conNum=1' />"
	s += "<param name='quality' value='high' />"
	s += "<param name='bgcolor' value='#F1F7FC' />"
 	s += "<param name='scale' value='noscale' />"
	s += "<param name='salign' value='lt' />"
	s += "<embed src='http://66.132.232.43/creatingfamiliesvideo/VideoPlayer.swf' width='320' height='274' align='middle' quality='high' bgcolor='#F1F7FC' scale='noscale' salign='lt' FlashVars='flvURL=" + strURL + "&ControlPanelColor=0xffffff&buttonColor=0x383838&ControlPanelPosition=0&showControlPanel=1&ShowtimeColor=0xffffff&bAutoPlay=1&bAutoRepeat=0&BufferTime=5&tmeColor=0x800000&loaColor=0x2a2a2a&GroundColor=0x2a2a2a&conNum=1' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />"
	s += "</object>"
	
	return s;

}
