/* javascript */
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function setVisible(iPath,title_img) {
	grayOut(true);
        w = (f_clientWidth() - 350)/2;
        h = ((f_clientHeight()  - 350)/2) + f_scrollTop();
	newObj = document.getElementById('imgpop');

	if(!newObj)
		newObj = document.createElement("div");

	newObj.id = "imgpop";
	var myBody = document.getElementsByTagName("body")[0];
	myBody.appendChild(newObj);

	newObj.style.left = w + 'px' ;
	newObj.style.top = h + 'px' ;

	newObj.style.width = '350px';
//	newObj.style.height = '350px';
	newObj.style.borderColor = '#000';
	newObj.style.borderWidth = "1px";
	newObj.style.borderStyle = "solid";
	newObj.style.backgroundColor = '#FFC209';
	newObj.style.position = "absolute";
	newObj.style.padding = "15px";
	newObj.style.zIndex = "60";

	newObj.innerHTML =
		'<p><img src="'+ iPath + '" class="img" width="345" /></p><p align="center"><b>'+title_img+'</b></p><p>' +
		'<a href="javascript:void(0);" onClick="rmLayer(\'imgpop\');">Close</a>';

	newObj.style.visibility = 'visible';
	newObj.style.display = 'block';
}

function rmLayer(divId) {
	oldObj = document.getElementById(divId);
	if(oldObj) {
		oldObj.style.display = 'none';
		delete oldObj;
	}
	grayOut(false);
}

function grayOut(vis, options) {
// Pass true to gray out screen, false to ungray
// options are optional.  This is a JSON object with the following (optional) properties
// opacity:0-100         // Lower number = less grayout higher = more of a blackout
// zindex: #             // HTML elements with a higher zindex appear on top of the gray out
// bgcolor: (#xxxxxx)    // Standard RGB Hex color code
// grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
// Because options is JSON opacity/zindex/bgcolor are all optional and can appear
// in any order.  Pass only the properties you need to set.
var options = options || {};
var zindex = options.zindex || 50;
var opacity = options.opacity || 70;
var opaque = (opacity / 100);
var bgcolor = options.bgcolor || '#000000';
var dark=document.getElementById('darkenScreenObject');
if (!dark) {
	// The dark layer doesn't exist, it's never been created.  So we'll
	// create it here and apply some basic styles.
	// If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
	var tbody = document.getElementsByTagName("body")[0];
	var tnode = document.createElement('div');           // Create the layer.
	tnode.style.position='absolute';                 // Position absolutely
	tnode.style.top='0px';                           // In the top
	tnode.style.left='0px';                          // Left corner of the page
	tnode.style.overflow='hidden';                   // Try to avoid making scroll bars
	tnode.style.display='none';                      // Start out Hidden
	tnode.id='darkenScreenObject';                   // Name it so we can find it later
	tbody.appendChild(tnode);                            // Add it to the web page
	dark=document.getElementById('darkenScreenObject');  // Get the object.
 }
 if (vis) {
	// Calculate the page width and height
	if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
		var pageWidth = document.body.scrollWidth+'px';
		var pageHeight = document.body.scrollHeight+'px';
	} else if( document.body.offsetWidth ) {
		var pageWidth = document.body.offsetWidth+'px';
		var pageHeight = document.body.offsetHeight+'px';
	} else {
		var pageWidth='100%';
		var pageHeight='100%';
	}
	//set the shader to cover the entire page and make it visible.
	dark.style.opacity=opaque;
	dark.style.MozOpacity=opaque;
	dark.style.filter='alpha(opacity='+opacity+')';
	dark.style.zIndex=zindex;
	dark.style.backgroundColor=bgcolor;
	dark.style.width= pageWidth;
	dark.style.height= pageHeight;
	dark.style.display='block';
} else {
	dark.style.display='none';
}
}

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("Invalid E-mail ID");
		   return false;
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID");
		   return false;
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID");
		    return false;
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID");
		    return false;
		 }
}

function validate_registerfrm() {
	alert(document.registerfrm.subcast.value);
	if ( document.registerfrm.firstname.value == '' ) {
		alert('Please Enter Firstname!');
		document.registerfrm.firstname.focus();
		return false;
	}
	if ( document.registerfrm.lastname.value == '' ) {
		alert('Please Enter Lastname!');
		document.registerfrm.lastname.focus();
		return false;
	}
	
	if ( document.registerfrm.address.value == '' ) {
		alert('Please Enter ur address!');
		document.registerfrm.address.focus();
		return false;
	}
	
	if ( document.registerfrm.city.value == '' ) {
		alert('Please Enter City!');
		document.registerfrm.city.focus();
		return false;
	}
	
	if ( document.registerfrm.state.value == '' ) {
		alert('Please Enter State!');
		document.registerfrm.state.focus();
		return false;
	}
	
	if ( document.registerfrm.zip.value == '' ) {
		alert('Please Enter Zip Code!');
		document.registerfrm.zip.focus();
		return false;
	}
	if ( document.registerfrm.country.value == '' ) {
		alert('Please Enter country!');
		document.registerfrm.country.focus();
		return false;
	}
	if ( document.registerfrm.phone.value == '' ) {
		alert('Please Enter Phone Number!');
		document.registerfrm.phone.focus();
		return false;
	}
	
	var f = document.registerfrm.email;
	if ( ( f.value == null ) || ( f.value == "" ) )	{
	    alert("Please Enter Email address!");
		f.focus();
		return false;
	}
	if ( echeck(f.value) == false )
	{
	    f.value = "";
		f.focus();
		return false;
	}
	if ( document.registerfrm.password.value == '' ) {
		alert('Please Enter Password!');
		document.registerfrm.password.focus();
		return false;
	}
	if ( document.registerfrm.cpassword.value == '' ) {
		alert('Please Enter Confirm Password!');
		document.registerfrm.cpassword.focus();
		return false;
	}
	if ( document.registerfrm.cpassword.value !=  document.registerfrm.password.value ) {
		alert('Password and Confirm password does not match!');
		document.registerfrm.cpassword.focus();
		return false;
	}
	if ( document.registerfrm.confirmtext.value == "" ) {
		alert("Please Enter Text Shown in image");
		  document.registerfrm.confirmtext.focus();
		  return false;
	}
}

