function showHide(obj,itemtype,itemuuid,linktoggle)
{
	cdiv = document.getElementById(obj);

	if (cdiv.style.display=='none')
	{
		if (cdiv.innerHTML=='')
		{
			window.frames['if_comments'].location.replace('http://www.hdsin.com/comments.php?obj='+obj+'&itemuuid='+itemuuid+'&itemtype='+itemtype);
		}
		cdiv.style.display='block';
		document.getElementById(linktoggle+'-show').style.display='none';
		document.getElementById(linktoggle+'-hide').style.display='block';
	}
	else
	{
		cdiv.style.display='none';		
		document.getElementById(linktoggle+'-hide').style.display='none';
		document.getElementById(linktoggle+'-show').style.display='block';
	}	 
}
function onoff(id)
{
	if (document.getElementById(id).style.display=='none')
		changeto = 'block';
	
	if (document.getElementById(id).style.display=='block')
		changeto = 'none';

	document.getElementById(id).style.display=changeto;		
}

// Pop up properties
function popUp(location)
{
    winLeft = 0;
    winTop = 0; 
    newwindow=window.open(location,'HDSIN','toolbar=no,border=no,menubar=no,resizable=no,width=700,height=700, scrollbars=yes,left='+winLeft+',top='+winTop);
	if (window.focus) {newwindow.focus()}
}

// Display Logo
function showLogo()
{
    document.getElementById("logo").innerHTML = "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='https://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='332' height='88' id='logo' align='middle'><param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='/logo.swf' /><param name='loop' value='false' /><param name='menu' value='false' /><param name='quality' value='high' /><param name='bgcolor' value='#ffffff' /><param name='wmode' value='transparent'/><embed src='/logo.swf' wmode='transparent' loop='false' menu='false' quality='high' bgcolor='#ffffff' width='332' height='88' name='logo' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
}


var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


function resizeit(offset)
{
	if (document.all){curwidth=(document.body.clientWidth);}else{curwidth=(window.innerWidth);}
	curwidth = curwidth-offset;
	popwidth=curwidth-(Math.round(curwidth/2)+Math.round(itemwidth/2));
	document.getElementById("dwindow").style.left=popwidth+"px";
	document.getElementById('overlaybase').style.width=(curwidth)+"px";

}

var doneload=0;
var opacity = 70;
var fadeOutInterval = null;
var fadeInInterval = null;
var objopacity = 0;
var destination = null;


function fadeInObj (obj) {
	
	currentElement = document.getElementById(obj);  

	if (currentElement.style.opacity < 0) {
		
		objopacity     = (currentElement.style.opacity*100) + 20;
		objopacityTemp  = objopacity / 100;	
		//alert (objopacity+' '+objopacityTemp);
		
		if (currentElement.filters)
			currentElement.style.filter = "alpha(opacity="+objopacity+")";

		currentElement.style.MozOpacity = objopacityTemp;
		currentElement.style.KhtmlOpacity = objopacityTemp;
		currentElement.style.opacity = objopacityTemp;
		
		if (objopacityTemp < .7)
		{
			fadeInObjInterval = setTimeout("fadeInObj('"+obj+"')", 10);
		}
		else
		{
			clearTimeout(fadeInObjInterval);
			
			window.frames['cframe'].location.replace(destination);
			//alert(destination);
		}
		
	} 
	else
	{
		window.frames['cframe'].location.replace(destination);
	}
}


function fadeOutObj (obj) {
	
	currentElement = document.getElementById(obj);  

	if (currentElement.style.opacity >1) {
		
		objopacity     = (currentElement.style.opacity*100) - 20;
		objopacityTemp  = objopacity / 100;	
		//alert (objopacity+' '+objopacityTemp);
		
		if (currentElement.filters)
			currentElement.style.filter = "alpha(opacity="+objopacity+")";

		currentElement.style.MozOpacity = objopacityTemp;
		currentElement.style.KhtmlOpacity = objopacityTemp;
		currentElement.style.opacity = objopacityTemp;
		
		if (objopacity !=0)
		{
			fadeOutObjInterval = setTimeout("fadeOutObj('"+obj+"')", 10);
		}
		else
		{
			clearInterval(fadeOutObjInterval);
			currentElement.style.display='none';
			document.getElementById("dwindow").style.display="none"; 
			if (itemwidth=='600')
			{
				window.frames['cframe'].location.replace('/popmovie.php?f=/img/loading_600.gif');
			}
			else
			{
				window.frames['cframe'].location.replace('/pop.php?f=/img/loading.gif');
			}
			//alert(currentElement.style.opacity);
		}
		
	} 
	else
	{
		currentElement.style.display='none';
			document.getElementById("dwindow").style.display="none"; 
			if (itemwidth=='600')
			{
				window.frames['cframe'].location.replace('/popmovie.php?f=/img/loading_600.gif');
			}
			else
			{
				window.frames['cframe'].location.replace('/pop.php?f=/img/loading.gif');
			}
	}
}
function closeit()
{ 
	//fadeOutObj('overlaybase');
	//alert(document.frames['if_minutesAvailable'].location);
	//document.frames['if_minutesAvailable'].location.reload(true);
	//parent.document.getElementById('overlaybase').style.display='none';
}

var nextImage='';

function fadeInImg (obj) {
	
	currentElement = document.getElementById(obj);  

	if (currentElement.style.opacity < 1) {
		
		objopacity     = (currentElement.style.opacity*100) + 25;
		objopacityTemp  = objopacity / 100;	
		//alert (objopacity+' '+objopacityTemp);
		
		if (currentElement.filters)
			currentElement.style.filter = "alpha(opacity="+objopacity+")";

		currentElement.style.MozOpacity = objopacityTemp;
		currentElement.style.KhtmlOpacity = objopacityTemp;
		currentElement.style.opacity = objopacityTemp;
		
		if (objopacityTemp < 1)
		{
			fadeInImgInterval = setTimeout("fadeInImg('"+obj+"')", 10);
		}
		else
		{
			clearTimeout(fadeInImgInterval);
			
			//window.frames['cframe'].location.replace(destination);
			//alert(destination);
		}
		
	} 
}


function fadeOutImg (obj) {
	
	currentElement = document.getElementById(obj);  

	if (currentElement.style.opacity >0) {
		
		objopacity     = (currentElement.style.opacity*100) - 25;
		objopacityTemp  = objopacity / 100;	
		//alert (objopacity+' '+objopacityTemp);
		
		if (currentElement.filters)
			currentElement.style.filter = "alpha(opacity="+objopacity+")";

		currentElement.style.MozOpacity = objopacityTemp;
		currentElement.style.KhtmlOpacity = objopacityTemp;
		currentElement.style.opacity = objopacityTemp;
		
		if (objopacity !=0)
		{
			fadeOutImgInterval = setTimeout("fadeOutImg('"+obj+"')", 10);
		}
		else
		{
			clearInterval(fadeOutImgInterval);
			document.getElementById('frameImage').src=nextImage;
			fadeInImg('frameImage');
			//alert(currentElement.style.opacity);
		}
		
	} 
}



function favoriteAction(i,action,type,subid)
{
	window.frames['favoriteFrame'].location.replace('/do_favorite.php?i='+i+'&do='+action+'&type='+type+'&subid='+subid);
}


function echeck(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
	   alert("That is not a valid email address.")
	   return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   alert("That is not a valid email address.")
	   return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("That is not a valid email address.")
		return false
	}

	 if (str.indexOf(at,(lat+1))!=-1){
		alert("That is not a valid email address.")
		return false
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("That is not a valid email address.")
		return false
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
		alert("That is not a valid email address.")
		return false
	 }
	
	 if (str.indexOf(" ")!=-1){
		alert("That is not a valid email address.")
		return false
	 }

	 return true					
}

function validateLoginForm(f)
{
	var emailID=f.email;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email address.")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.focus()
		return false
	}
	if (f.captcha.value.length > 0)
	{
		alert("Please do not enter the security code.");
		f.captcha.blur();
		return false;
	}
	if (f.pp.value.length < 4)
	{
		alert("Please enter your password.");
		f.pp.focus();
		return false;
	}
	f.password.value=strmd5(f.pp.value);
	f.pp.value='';
	return true;
}

function validateRegisterForm(f)
{
	if (f.purchaseMinutes.value < 1)
	{
		alert("Please select a package to purchase.");
		//f.packageMinutes.focus();
		return false;
	}
	
	var emailID=f.email;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email address.")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.focus()
		return false
	}
	
	if (emailvalid==false)
	{
		alert("Please check your email address.");
		return false;
	}

	if (f.password.value.length < 4)
	{
		alert("Please enter a password.");
		f.password.focus();
		return false;
	}

	if (f.password.value != f.password_confirm.value)
	{
		alert("Make sure the two passwords match.");
		f.password.value=''; f.password_confirm.value='';
		f.password.focus();
		return false;
	}

	if (passvalid==false)
	{
		alert("Please check your password strength.");
		return false;
	}
	
	if (f.age.checked==false)
	{
		alert("Please complete the age verifcation.");
		f.age.focus();
		return false;
	}	

	if (f.firstName.value.length < 1)
	{
		alert("Please enter your first name.");
		f.firstName.focus();
		return false;
	}

	if (f.lastName.value.length < 2)
	{
		alert("Please enter your last name.");
		f.lastName.focus();
		return false;
	}

	if (f.address1.value.length < 8)
	{
		alert("Please enter your street address.");
		f.address1.focus();
		return false;
	}

	if (f.city.value.length < 3)
	{
		alert("Please enter the name of your city.");
		f.city.focus();
		return false;
	}

	if (f.state.options[f.state.selectedIndex].value=='')
	{
		alert("Please select your state or province.");
		f.state.focus();
		return false;
	}

	if (f.zip.value.length < 3)
	{
		alert("Please enter your zip / zip code.");
		f.zip.focus();
		return false;
	}

	if (f.country.options[f.country.options.selectedIndex].text=='')
	{
		alert("Please select your country of residence.");
		f.country.focus();
		return false;
	}

	if (f.city.value.length < 3)
	{
		alert("Please enter the name of your city.");
		f.city.focus();
		return false;
	}
	
	
	return true;
}


function validateArtieRegisterForm(f)
{
	
	var emailID=f.email;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email address.")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.focus()
		return false
	}
	
	if (emailvalid==false)
	{
		alert("Please check your email address.");
		return false;
	}
	
	if (f.firstName.value.length < 1)
	{
		alert("Please enter your First Name");
		f.firstName.focus();
		return false;
	}

	if (f.lastName.value.length < 1)
	{
		alert("Please enter your Last Name");
		f.lastName.focus();
		return false;
	}


	if (f.password.value.length < 4)
	{
		alert("Please enter a password.");
		f.password.focus();
		return false;
	}

	if (f.password.value != f.password_confirm.value)
	{
		alert("Make sure the two passwords match.");
		f.password.value=''; f.password_confirm.value='';
		f.password.focus();
		return false;
	}

	if (passvalid==false)
	{
		alert("Please check your password strength.");
		return false;
	}
	
	if (f.age.checked==false)
	{
		alert("Please complete the age verifcation.");
		f.age.focus();
		return false;
	}	

	if (f.firstName.value.length < 1)
	{
		alert("Please enter your first name.");
		f.firstName.focus();
		return false;
	}

	if (f.lastName.value.length < 2)
	{
		alert("Please enter your last name.");
		f.lastName.focus();
		return false;
	}

	if (f.address1.value.length < 8)
	{
		alert("Please enter your street address.");
		f.address1.focus();
		return false;
	}

	if (f.city.value.length < 3)
	{
		alert("Please enter the name of your city.");
		f.city.focus();
		return false;
	}

	if (f.state.options[f.state.selectedIndex].value=='')
	{
		alert("Please select your state or province.");
		f.state.focus();
		return false;
	}

	if (f.zip.value.length < 3)
	{
		alert("Please enter your zip / zip code.");
		f.zip.focus();
		return false;
	}

	if (f.country.options[f.country.options.selectedIndex].text=='')
	{
		alert("Please select your country of residence.");
		f.country.focus();
		return false;
	}

	if (f.city.value.length < 3)
	{
		alert("Please enter the name of your city.");
		f.city.focus();
		return false;
	}
	
	
	return true;
}


function validateMainMinuteForm(f)
{
	if (f.purchaseMinutesMain.value<1)
	{
		alert("Please select a package to purchase.");
		//f.packageMinutes.focus();
		return false;
	}
	else
	{
	
		return true;
	}
}


function validateMinuteForm(f)
{
	if (f.purchaseMinutes.value<1)
	{
		alert("Please select a package to purchase.");
		//f.packageMinutes.focus();
		return false;
	}
	else
	{
	
		return true;
	}
}


function validateAccountForm(f)
{
	if (sitenamevalid==false)
	{
		alert("Please fix your chosen site name.");
		return false;
	}
	if (f.firstName.value.length < 1)
	{
		alert("Please enter your first name.");
		f.firstName.focus();
		return false;
	}

	if (f.lastName.value.length < 2)
	{
		alert("Please enter your last name.");
		f.lastName.focus();
		return false;
	}

	if (f.address1.value.length < 8)
	{
		alert("Please enter your street address.");
		f.address1.focus();
		return false;
	}

	if (f.city.value.length < 3)
	{
		alert("Please enter the name of your city.");
		f.city.focus();
		return false;
	}

	if (f.state.options[f.state.selectedIndex].value=='')
	{
		alert("Please select your state or province.");
		f.state.focus();
		return false;
	}

	if (f.zip.value.length < 3)
	{
		alert("Please enter your zip / zip code.");
		f.zip.focus();
		return false;
	}

	if (f.country.options[f.country.options.selectedIndex].text=='')
	{
		alert("Please select your country of residence.");
		f.country.focus();
		return false;
	}

	if (f.city.value.length < 3)
	{
		alert("Please enter the name of your city.");
		f.city.focus();
		return false;
	}

	var emailID=f.email;
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email address.")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.focus()
		return false
	}

	if (emailvalid==false)
	{
		alert("Please check your email address.");
		return false;
	}

	if (f.password_current.value.length < 4)
	{
		alert("Please enter your current password.");
		f.password_current.focus();
		return false;
	}

	if (f.password.value.length > 0)
	{
		if (f.password.value.length < 4)
		{
			alert("Please enter a new password at least 5 characters long.");
			f.password.focus();
			return false;
		}

		if (f.password.value != f.password_confirm.value)
		{
			alert("Make sure the two new passwords match.");
			f.password.value=''; f.password_confirm.value='';
			f.password.focus();
			return false;
		}
		if (passvalid==false)
		{
			alert("Please check your password strength.");
			return false;
		}
	}
	
	
	return true;
}

//Upper-left Link Properties on How it works page
function styleLinkHiw(href, activeLink)
{
	document.getElementById("hiwSection1").style.color = "#FFFFFF";
	document.getElementById("hiwSection2").style.color = "#FFFFFF";
	document.getElementById("hiwSection3").style.color = "#FFFFFF";
	document.getElementById(activeLink).style.color = "#FFCC00";		
	howitworksFrame.location.href=href;	
}

function hide_form(frm_id)
{
	document.getElementById(frm_id).style.visibility = 'hidden';
}

function checkBrowser()
{
	var nVer = navigator.appVersion;
	var nAgt = navigator.userAgent;
	var browserName  = '';
	var fullVersion  = 0; 
	var majorVersion = 0;
	
	// In Internet Explorer, the true version is after "MSIE" in userAgent
	if ((verOffset=nAgt.indexOf("MSIE"))!=-1) {
	 browserName  = "Microsoft Internet Explorer";
	 fullVersion  = parseFloat(nAgt.substring(verOffset+5));
	 majorVersion = parseInt(''+fullVersion);
	}
	
	// In Opera, the true version is after "Opera" 
	else if ((verOffset=nAgt.indexOf("Opera"))!=-1) {
	 browserName  = "Opera";
	 fullVersion  = parseFloat(nAgt.substring(verOffset+6));
	 majorVersion = parseInt(''+fullVersion);
	}
	
	// In Firefox, the true version is after "Firefox" 
	else if ((verOffset=nAgt.indexOf("Firefox"))!=-1) {
	 browserName  = "Firefox";
	 fullVersion  = parseFloat(nAgt.substring(verOffset+8));
	 majorVersion = parseInt(''+fullVersion);
	}
	
	// In most other browsers, "name/version" is at the end of userAgent 
	else if ( (nameOffset=nAgt.lastIndexOf(' ')+1) < (verOffset=nAgt.lastIndexOf('/')) ) 
	{
	 browserName  = nAgt.substring(nameOffset,verOffset);
	 fullVersion  = parseFloat(nAgt.substring(verOffset+1));
	 if (!isNaN(fullVersion)) majorVersion = parseInt(''+fullVersion);
	 else {fullVersion  = 0; majorVersion = 0;}
	}
	
	// Finally, if no name and/or no version detected from userAgent...
	if (browserName.toLowerCase() == browserName.toUpperCase()
	 || fullVersion==0 || majorVersion == 0 )
	{
	 browserName  = navigator.appName;
	 fullVersion  = parseFloat(nVer);
	 majorVersion = parseInt(nVer);
	}
	
	if(browserName=="Firefox" && fullVersion < 3)
	{
		/*
		msg="Oops! You appear to be using FireFox Version 2. In order to safeguard the private information of our users HDSin.com has upgraded the security protocols of our servers.";	
		msg+="\n\nPlease click OK to download the latest FireFox Version to enjoy high definition adult entertainment in a secure, private environment.";
		msg+="\n\nThanks,";	
		msg+="\nThe HDSin.com team";	
	
		answer = confirm(msg);
		
		if(answer)
		{
			window.open("http://www.mozilla.com/en-US/firefox/");
		}
		return "incompatible";
		*/
	}
}