/*=============================================================================
|| ##################################################################
||	phpFoX Portal
|| ##################################################################
||	
||	Copyright		: (C) 2005 The phpFoX Group a Reality Fox Creation
||	Contact		: support@phpfox.com
||	Support Forum	: http://www.phpfox.com/forum/
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws. 
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.). 
||
||	- You may also not remove the "Powered By phpFoX" or any copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations). 
||
||	- phpFoX is NOT a FREE software - http://www.phpfox.com/license
||
|| ##################################################################
=============================================================================*/

function showIt()
{	
	var item = document.getElementById('location');

	if (item.value == "United_States")
	{
		

		document.getElementById('state').disabled=false;
		document.getElementById('zip').disabled=false;	
	}
	else
	{
		document.getElementById('state').disabled=true;
		document.getElementById('zip').disabled=true;	
	}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function resetElementValue(frmElement,goodValue)
{
	alert(frmElement.value+' = '+goodValue);
	if(frmElement.value != goodValue)
	{
		alert(frmElement.value+' = '+goodValue);
		frmElement.value = goodValue;
	}
}

function SelectAllList(elementName){
	var CONTROL = document.getElementsByName(elementName);
	var selBoxObj = CONTROL[0];
	if (selBoxObj.length)
	{
		for (i=0;i<selBoxObj.length;i++)
		{
			selBoxObj.options[i].selected = true;
		}
	}
	else
	{
		return;
	}
}

function DeselectAllList(elementName){
	var CONTROL = document.getElementsByName(elementName);
	var selBoxObj = CONTROL[0];
	if (selBoxObj.length)
	{
		for (i=0;i<selBoxObj.length;i++)
		{
			selBoxObj.options[i].selected = false;
		}
	}
	else
	{
		return;
	}

}

function bookmark(url, description)
	{
	netscape="Gecko User's hit CTRL+D to add a bookmark to this site."
	if (navigator.appName=='Microsoft Internet Explorer')
		{
		window.external.AddFavorite(url, description);
		}
	else if (navigator.appName=='Netscape')
		{
		alert(netscape);
		}
	}


function popUp2(URL,WIDTH,HEIGHT,SCROLL,LEFT,TOP) 
	{
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "','scrollbars="+ SCROLL +",width="+ WIDTH +",height="+ HEIGHT +",left = "+ LEFT +",top = "+ TOP +"');");
	}


function openIMWindow(theURL,winName,features) { //v2.0
	windowOpener(theURL,winName,features);
}


function windowOpener(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

/*###############################
	PROGRESS BAR
###############################*/

var progressEnd;		
var progressInterval;	
var progressAt;
var progressTimer;

function do_prog(item1,item2) 
{
	progressEnd = item1;		
	progressInterval = item2;	
	progressAt = progressEnd;
	progress_update();
}

function progress_clear() 
{
	for (var i = 1; i <= progressEnd; i++) document.getElementById('progress'+i).className = 'pbar1';
	progressAt = 0;
}

function progress_update() 
{
	progressAt++;
	if (progressAt > progressEnd) progress_clear();
	else document.getElementById('progress'+progressAt).className = 'pbar2';
	progressTimer = setTimeout('progress_update()',progressInterval);
}

function progress_stop() 
{
	clearTimeout(progressTimer);
	progress_clear();
}

/*###############################
	MENU MOUSEOVER
###############################*/

function linkon1(id1)
{
	document.getElementById(id1).className='menu5b';

}

function linkon2(id1)
{
	document.getElementById(id1).className='menu5a';

}


/*###############################
	COOKIES
###############################*/


function SetCookie(cookieName,cookieValue,nDays) 
{
	var today = new Date();
	var expire = new Date();
 	if (nDays==null || nDays==0) nDays=1;
 	expire.setTime(today.getTime() + 3600000*24*nDays);
 	document.cookie = cookieName+"="+escape(cookieValue)+";expires="+expire.toGMTString();
}

function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}



/*###############################
	HIDE MENUS
###############################*/

if (document.getElementById) { 
	document.write('<style type="text/css">\n')
	document.write('.submenu{display:;}\n')
	document.write('</style>\n')
}


function SwitchMenu(obj,id2,min_max_id)
{

	var args = SwitchMenu.arguments;

	/*
	alert("ARG0 "+args[0]);
	alert("ARG1 "+args[1]);
	alert("ARG2 "+args[2]);
	alert("ARG3 "+args[3]);
	*/
	
	if(args[2] == undefined)
	{
		var linkTextMin = '[-]';
	}
	else
	{
		var linkTextMin = args[2];
	}

	if(args[3] == undefined)
	{
		var linkTextMax = '[+]';
	}
	else
	{
		var linkTextMax = args[3];
	}

	if(document.getElementById) {
	var el = document.getElementById(obj);
	
		if(el.style.display == "none") { 
			
			if(min_max_id!=""){
				getMinMaxPageData(min_max_id,"2");
			}
			
			//document.getElementById(id2).innerHTML=linkTextMin;
			document.getElementById(id2).innerHTML="[-]";
			el.style.display = "";
			SetCookie(obj,"","-1"); 
		} 
		else { 
		
			if(min_max_id!=""){
				getMinMaxPageData(min_max_id,"1");
			}

			//document.getElementById(id2).innerHTML=linkTextMax;
			document.getElementById(id2).innerHTML="[+]";
			el.style.display = "none";
			SetCookie(obj,1,0); 
		}
	}
}


function SwitchMenu2(obj,id2,id3,id4,id5,id6,id7,id8)
{
	if(document.getElementById) {
	var el = document.getElementById(obj);
	
		if(el.style.display == "none") { 
			document.getElementById(id6).innerHTML=id7;
			document.getElementById(id2).src=id5;
			el.style.display = "";
			SetCookie(obj,"","-1"); 
			document.getElementById(id3).style.width='70%';
		} else { 
			document.getElementById(id6).innerHTML=id8;
			document.getElementById(id2).src=id4;
			el.style.display = "none";
			SetCookie(obj,1,0); 
			document.getElementById(id3).style.width='100%';
		}
	}
}




/*###############################
	GO TO LOCATION / FRAMES
###############################*/
function go_home(link)
{
	if (top.frames.length == 0) {
    		document.cookie = "newURL=" + escape(document.URL) + "; path=/;"
    		ver = parseInt(navigator.appVersion, 10);
    		if ( ((navigator.appName == "Netscape") && (ver >= 3)) ||
         		((navigator.appName == "Microsoft Internet Explorer") && (ver >= 4)) )
      			location.replace(link);
    		else
	      location = link;
    		};
}



/*###############################
	NO RIGHT CLICK
###############################*/
function clickIE() 
	{
	if (document.all) 
		{
		return false;
		}
	}

function clickNS(e) 
	{
	if (document.layers||(document.getElementById&&!document.all)) 
		{
		if (e.which==2||e.which==3) 
			{
			return false;
			}
		}
	}


function noCLICK()
{
	
	if (document.layers) {
		document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;
	} else {
	document.onmouseup=clickNS;document.oncontextmenu=clickIE;
	}
	document.oncontextmenu=new Function("return false")
}



function jumpTo(list)
{
	var IDS = document.getElementById(list);
	
	if (IDS.value != "") {
		window.location.href=IDS.value;
	} 
	
	return false;
}






function image1(img,height,width)
{
	if (getCookie('FOX_EN')) { showInfo3(img,width,height); }
	return false;
}


function image2()
{
	if (getCookie('FOX_EN')) { nd(); }
	return false;
}


function image3(type)
{
	if (getCookie('FOX_EN')) {
		SetCookie("FOX_EN","","-1");
	} else {
		SetCookie("FOX_EN",1,0);
	}	
}




/*###############################
	IMAGE FADER
###############################*/
function initImage(ids) {
  imageId = ids;
  image = document.getElementById(imageId);
  setOpacity(image, 0);
  image.style.visibility = 'visible';
  fadeIn(imageId,0);
}


function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}


function fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 100);
    }
  }
}





/*###############################
	INSERT TEXT AT CURSOR
###############################*/
function insertAtCursor(myField, myValue, type) 
{
	if ( displayIt == "True" )
	{
		var newValue = myValue.replace(":","");
		var mainValue = newValue.replace(":","");
		var html = '<img src="'+ SciptHome +'/images/smile/emo/'+ mainValue +'.gif">';
		tinyMCE.execCommand('mceInsertContent', false, html);
		return;
	}
	else
	{
		if (document.selection) 
		{
			myField.focus();
			if (type == 1) {
			sel = opener.document.selection.createRange();
		} else {
			sel = document.selection.createRange();
		}
		sel.text = myValue;
	}
	else if (myField.selectionStart || myField.selectionStart == '0') 
	{
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)
		+ myValue
		+ myField.value.substring(endPos, myField.value.length);
		myField.focus();
	} 
	else 
	{
		myField.value += myValue;
		}
	}
}







function sel(idname) {
	with(document.myform) {
		for(i=0;i<elements.length;i++) {
			thiselm = elements[i];
			if(thiselm.name.substring(0,2) == 'id')
				thiselm.checked = !thiselm.checked
		}
	}
}

function showInfo5(name) 
{
	var newhtml = ''+name+'';

	return overlib(newhtml,WRAP,BGCOLOR,"#00004D",FGCOLOR,"#F6F6F6",TEXTSIZE,"10px",BORDER,2,CELLPAD,5)
}

function showInfo4(name,location,mood) 
{
	var newhtml = '<img src="'+location+'" alt="" width="18" height="12" style="vertical-align:middle;" /> '+name+' '+mood+'';

	return overlib(newhtml,WRAP,BGCOLOR,"#00004D",FGCOLOR,"#F6F6F6",TEXTSIZE,"10px",BORDER,2,CELLPAD,5)
}
	
function showInfo2(name) 
{
	var newhtml = ''+name+'';

	return overlib(newhtml,WRAP,BGCOLOR,"#00004D",FGCOLOR,"#F6F6F6",TEXTSIZE,"10px",BORDER,2,CELLPAD,5)
}

function resizeImage(pWidth,pbucketFrame,imgId,wrapperId)
{
	var inurl = document.getElementById(wrapperId).innerHTML;
	var imgWidth = document.getElementById(imgId).width;
	var imgHeight = document.getElementById(imgId).height;
	var imgSrc = document.getElementById(imgId).src;
	var imageSource = '';

	if(imgWidth > pWidth)
	{
		var pctdiff = pWidth / imgWidth;
		var newWidth = imgWidth * pctdiff;
		var newHeight = imgHeight * pctdiff;

		document.getElementById(wrapperId).innerHTML = "";
		document.getElementById(wrapperId).innerHTML =  "<img src='" + imgSrc + "' height='" + newHeight + "' width='" + newWidth + "' id='" + imgId + "' >";
		document.getElementById(wrapperId).style.height = newHeight + 'px';
		document.getElementById(wrapperId).style.width = newWidth + 'px';
	}
	else
	{
		document.getElementById(wrapperId).style.height = imgHeight + 'px';
		document.getElementById(wrapperId).style.width = imgWidth + 'px';
	}
	if(pbucketFrame)
	{
		var pctdiff = 450 / imgWidth;
		if(pctdiff > 0)
		{
			var newWidth = Math.floor(imgWidth * pctdiff);
			var newHeight = Math.floor(imgHeight * pctdiff);
		}
		else
		{
			var newWidth = imgWidth;
			var newHeight= imgHeight;
		}

		if(imageSource == '')
		{
			inurl = inurl.substring(0,inurl.lastIndexOf(">")) + " id='tmpimg' onLoad='resizeImage(200,true,\"tmpimg\",\"currentContent\");' />";
			srcSubStr = inurl.split('src="');
			imageSource = srcSubStr[1].split('"');
		}
		document.getElementById('imageUrl').value = imageSource[0];
		//document.getElementById('imageWidth').value = newWidth;
		//document.getElementById('imageHeight').value = newHeight;

		var pctdiff = 120 / imgWidth;
		if(pctdiff > 0)
		{
			var newWidth = Math.floor(imgWidth * pctdiff);
			var newHeight = Math.floor(imgHeight * pctdiff);
		}
		else
		{
			var newWidth = imgWidth;
			var newHeight= imgHeight;
		}

		//document.getElementById('thumbWidth').value = newWidth;
		//document.getElementById('thumbHeight').value = newHeight;
	}
}

function resizeVideo(pWidth,pbucketFrame,videoId,wrapperId)
{
	var inurl = document.getElementById(wrapperId).innerHTML;
	var videoWidth = document.getElementById(videoId).width;
	var videoHeight = document.getElementById(videoId).height;
	var videoSrc = document.getElementById(videoId).src;

	if(videoWidth > pWidth)
	{
		var pctdiff = pWidth / videoWidth;
		var newWidth = videoWidth * pctdiff;
		var newHeight = videoHeight * pctdiff;

		document.getElementById(wrapperId).innerHTML = "";
		document.getElementById(wrapperId).innerHTML = "<embed width='" + newWidth + "' height='" + newHeight + "' type='application/x-shockwave-flash' src='" + videoSrc + "' id='" + videoId + "' swliveconnect='true' quality='high' bgcolor='white'></embed>";
		document.getElementById(wrapperId).style.height = newHeight + 'px';
		document.getElementById(wrapperId).style.width = newWidth + 'px';
	}
	else
	{
		document.getElementById(wrapperId).style.height = videoHeight + 'px';
		document.getElementById(wrapperId).style.width = videoWidth + 'px';
	}
}

function showIMAlert(url) {
	newwindow=window.open(url,'CHATREQUEST','height=50,width=400,left=100,top=100,resizable=no,scrollbars=no,toolbar=no,status=no');
}

function showHideMediaHelp()
{
	if(document.getElementById('divhelp').style.display == 'block')
	{
		document.getElementById('divhelp').style.display='none';
		document.getElementById('helptext').innerHTML ='<img src="/images/maximize.gif" align="absmiddle" border="0" />SHOW HELP<img src="/images/maximize.gif" align="absmiddle" border="0" />';
	}
	else
	{
		document.getElementById('divhelp').style.display='block';
		document.getElementById('helptext').innerHTML ='<img src="/images/minimize.gif" align="absmiddle" border="0" />HIDE HELP<img src="/images/minimize.gif" align="absmiddle" border="0" />';
	}
}

function showHideElement(elemnt)
{
	if(document.getElementById(elemnt).style.display == 'block')
	{
		document.getElementById(elemnt).style.display='none';
	}
	else
	{
		document.getElementById(elemnt).style.display='block';
	}
}

var httpObjMinMax;


function loadXMLMinMax(){

	httpObjMinMaxJs = false;

	// branch for native XMLHttpRequest object
	if(window.XMLHttpRequest) {
		try {
			httpObjMinMaxJs = new XMLHttpRequest();
		}
		catch(e) {
			httpObjMinMaxJs = false;
		}

	// branch for IE/Windows ActiveX version
	} else if(window.ActiveXObject) {
		try {
			httpObjMinMaxJs = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e) {
			try {
				httpObjMinMaxJs = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e) {
				httpObjMinMaxJs = false;
			}
		}
	}

	return httpObjMinMaxJs;

}

function getMinMaxPageData(id,status){

	var mf_site_url="";

	httpObjMinMax = loadXMLMinMax();

	if(httpObjMinMax) {

		httpObjMinMax.abort();

		url=mf_site_url+"/inc/ajax/hb_min_max_ajax_src.php?div_id="+id+"&div_status="+status;
		
		//alert(url);

		httpObjMinMax.onreadystatechange = processMinMaxReqChange;

		httpObjMinMax.open("GET", url, true);

		httpObjMinMax.send("");
	}
	else{
		alert("no");
	}

}

function processMinMaxReqChange(){

	// only if httpObj shows "loaded"
	if (httpObjMinMax.readyState == 4) {

		// only if "OK"
		if (httpObjMinMax.status == 200) {
			//alert("inside response");
			var resResponse= httpObjMinMax.responseText;

			if(resResponse!="" && resResponse == "ERROR"){
				//alert("Error while call Min max ajax.");
			}
		}
		else {
			alert("There was a problem retrieving the Page Data :\n" +httpObjMinMax.statusText);
		}
	}
}


/*************************************************************
 *    DYNIFS - Dynamic IFrame Auto Size v1.0.0
 *
 *    Copyright (C) 2006, Markus (phpMiX)
 *    This script is released under GPL License.
 *    Feel free to use this script (or part of it) wherever you need
 *    it ...but please, give credit to original author. Thank you. :-)
 *    We will also appreciate any links you could give us.
 *    http://www.phpmix.org
 *
 *    Enjoy! ;-)
*************************************************************/

var DYNIFS = {
    // Storage for known IFrames.
    iframes: {},
    // Here we save any previously installed onresize handler.
    oldresize: null,
    // Flag that tell us if we have already installed our onresize handler.
    ready: false,
    // The document dimensions last time onresize was executed.
    dim: [-1,-1],
    // Timer ID used to defer the actual resize action.
    timerID: 0,
    // Obtain the dimensions (width,height) of the given document.
    getDim: function(d) {
        var w=200, h=200, scr_h, off_h;
        if( d.height ) { return [d.width,d.height]; }
        with( d.body ) {
            if( scrollHeight ) { h=scr_h=scrollHeight; w=scrollWidth; }
            if( offsetHeight ) { h=off_h=offsetHeight; w=offsetWidth; }
            if( scr_h && off_h ) h=Math.max(scr_h, off_h);
        }
        return [w,h];
    },
    // This is our window.onresize handler.
    onresize: function() {
        // Invoke any previously installed onresize handler.
        if( typeof this.oldresize == 'function' ) { this.oldresize(); }
        // Check if the document dimensions really changed.
        var dim = this.getDim(document);
        if( this.dim[0] == dim[0] && this.dim[1] == dim[1] ) return;
        // Defer the resize action to prevent endless loop in quirksmode.
        if( this.timerID ) return;
        this.timerID = setTimeout('DYNIFS.deferred_resize();', 10);
    },
    // This is where the actual IFrame resize is invoked.
    deferred_resize: function() {
        // Walk the list of known IFrames to see if they need to be resized.
        for( var id in this.iframes ) this.resize(id);
        // Store resulting document dimensions.
        this.dim = this.getDim(document);
        // Clear the timer flag.
        this.timerID = 0;
    },
    // This is invoked when the IFrame is loaded or when the main window is resized.
    resize: function(id) {
        // Browser compatibility check.
        if( !window.frames || !window.frames[id] || !document.getElementById || !document.body )
            return;
        // Get references to the IFrame window and layer.
        var iframe = window.frames[id];
        var div = document.getElementById(id);
        if( !div ) return;
        // Save the IFrame id for later use in our onresize handler.
        if( !this.iframes[id] ) {
            this.iframes[id] = true;
        }
        // Should we inject our onresize event handler?
        if( !this.ready ) {
            this.ready = true;
            this.oldresize = window.onresize;
            window.onresize = new Function('DYNIFS.onresize();');
        }
        // This appears to be necessary in MSIE to compute the height
        // when the IFrame'd document is in quirksmode.
        // OTOH, it doesn't seem to break anything in standards mode, so...
        if( document.all ) div.style.height = '0px';
        // Resize the IFrame container.
        var dim = this.getDim(iframe.document);
        div.style.height = (dim[1]+30) + 'px';
    }
};

