

// start script for launching external child window

function winLaunch (url) {
	window.open(url,'acknowledge','width=545,height=380,resizable')
}


function popupWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=515,height=375,screenX=150,screenY=150,top=150,left=150')
}

function shareWindow(url) {
  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=515,height=375,screenX=150,screenY=150,top=150,left=150')
}


function showPopUpDiv(regId, e, center, fileName)
{
	var pos = [2];
	pos = findPos(e);

 	var popup = document.createElement("div");
 	popup.id = "popup";
 	popup.setStyle = 'popDiv';
 	popup.style.zIndex = 100;
	
	loadContent(fileName,'popup');
	
	document.body.appendChild(popup);
	
	if(center == 'true')
	{
		popup.style.position = 'fixed';
		popup.style.left = '50%';
		popup.style.top = '200px';
		popup.style.marginLeft = '-100px';
	}
	else
	{
		popup.style.top = pos[1] + "px";
		popup.style.left = pos[0] + "px";
	}
}

function showPreview(mid, e, center)
{
	var pos = [2];
	pos = findPos(e);

 	var popup = document.createElement("div");
 	popup.id = "popup";
 	//popup.style.cssText = "position:absolute; text-align: center; width: 200px; left: 400px; top: 200px; height:auto; border: 2px solid #00CAF6; background-color: #FFFFFF; padding: 5px 5px 5px 5px; z-index: 100;";
	
	popup.setStyle = 'popDiv';
	
	loadContent('preview.php?id=' + mid,'popup');
	
	document.body.appendChild(popup);
	
	if(center == 'true')
	{
		popup.style.position = 'fixed';
		popup.style.left = '50%';
		popup.style.top = '200px';
		popup.style.marginLeft = '-100px';
	}
	else
	{
		popup.style.top = pos[1] + "px";
		popup.style.left = pos[0] + "px";
	}
}


function showPopUpMsg(msg)
{
 	var popup = document.createElement("div");
 	popup.id = "popupMsg";
 	
 	//popup.style.cssText = "position:absolute; text-align: center; width: 200px; left: 400px; top: 200px; height:auto; border: 2px solid #00CAF6; background-color: #FFFFFF; padding: 5px 5px 5px 5px; z-index: 100;";
	popup.setStyle = 'popDiv';
	
	popup.innerHTML = '<div class="popDivBody"><h1>SIMIAN SAYS:</h1>' + msg + '</div>';
	document.body.appendChild(popup);

	popup.style.position = 'fixed';
	popup.style.left = '50%';
	popup.style.top = '30px';
	popup.style.marginLeft = '-150px';
	popup.style.zIndex = '2000';
	
	// Set timer to close this popup
	

	setTimeout('hidePopUpDiv(\'popupMsg\')', 3500);

}

function infoPopup(msg)
{
 	var popup = document.createElement("div");
 	popup.id = "popupMsg";
 	
 	//popup.style.cssText = "position:absolute; text-align: center; width: 200px; left: 400px; top: 200px; height:auto; border: 2px solid #00CAF6; background-color: #FFFFFF; padding: 5px 5px 5px 5px; z-index: 100;";
	popup.setStyle = 'popDiv';
	
	popup.innerHTML = '<div class="popDivHdr"><div class="float_left" style="padding-top: 2px;">SIMIAN SAYS:</div><div class="float_right"><a href="javascript:void(0);" onclick="javascript:hidePopUpDiv(\'popupMsg\');"><img src="images/icon_x.gif" width="12" height="14" border="0"/></a></div></div><div class="popDivBody02">' + msg + '</div></div>';
	document.body.appendChild(popup);

	popup.style.position = 'fixed';
	popup.style.left = '50%';
	popup.style.top = '200px';
	popup.style.marginLeft = '-150px';
	popup.style.zIndex = '200';
}


function findPos(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
	do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);

	return [curleft,curtop];
	}
}

function hidePopUpDiv(id)
{
	var divObj = document.getElementById(id);
	document.body.removeChild(divObj);
}


function pageWidth() 
{
	var viewportwidth;
	var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }


	return viewportwidth;
	
	
}



function pageHeight() {

	var viewportwidth;
	var viewportheight;
 
 // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight
 
 if (typeof window.innerWidth != 'undefined')
 {
      viewportwidth = window.innerWidth,
      viewportheight = window.innerHeight
 }
 
// IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

 else if (typeof document.documentElement != 'undefined'
     && typeof document.documentElement.clientWidth !=
     'undefined' && document.documentElement.clientWidth != 0)
 {
       viewportwidth = document.documentElement.clientWidth,
       viewportheight = document.documentElement.clientHeight
 }
 
 // older versions of IE
 
 else
 {
       viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
       viewportheight = document.getElementsByTagName('body')[0].clientHeight
 }


	return viewportheight;
	

}

function urlencode( str ) {
                             
    var histogram = {}, tmp_arr = [];
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    
    // The histogram is identical to the one in urldecode.
    histogram["'"]   = '%27';
    histogram['(']   = '%28';
    histogram[')']   = '%29';
    histogram['*']   = '%2A';
    histogram['~']   = '%7E';
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    
    // Begin with encodeURIComponent, which most resembles PHP's encoding functions
    ret = encodeURIComponent(ret);
    
    for (search in histogram) {
        replace = histogram[search];
        ret = replacer(search, replace, ret) // Custom replace. No regexing
    }
    
    // Uppercase for full PHP compatibility
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
    
    return ret;
}



		function writePlayer(movieSrc)
		{
		 	document.write('<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="421" width="720">');	
		 	
		 			
			document.write('<param name="src" value="' + movieSrc + '">');
			document.write('<param name="autoplay" value="TRUE">');
			document.write('<param name="controller" value="true">');
			document.write('<param name="loop" value="false">');
			document.write('<param name="target" value="myself">');
			
			document.write('<param name="type" value="video/quicktime" >');	
			document.write('<param name="scale" value="tofit">');
			document.write('<param name="bgcolor" value="#000000">');
			document.write('<param name="showlogo" value="false">');		
			
			document.write('<embed height="421"	pluginspage="http://www.apple.com/quicktime/download/" src="' + movieSrc + '"');
			

			//document.write(' type="video/quicktime" scale="tofit" width="720" autoplay=TRUE controller=true loop=false qtsrcdontusebrowser=true></object>');
		}
		
		
