
var hostName = 'DOMAIN_PATH';
var currentPage = '';

function onLoadCommonFunction() {
	//MM_preloadImages('ADMIN_IMAGE_LINK/slide_right.jpg');
}

function popupWindow(path, where, hite, wide){
	if (window.event){ 
		window.event.returnValue = false;   
	}
	var width;
	var height;
	var imgWidth;
	var imgHeight;
	
	if (screen.width<wide){
		width=screen.width-20;
		imgWidth=width-10;
		var windowX = (screen.width-width)/2;
	}
	else{
		var windowX = (screen.width-wide)/2;
		width=wide;
	}

	if (screen.height<hite){
		height=screen.height-70;
		imgHeight=height-20;
		var windowY = (screen.height-height)/2-30;
	}
	else{
		var windowY = (screen.height-hite)/2-10;
		height=hite;
	}

	var rand_no = Math.random();
	var i = Math.round(100*Math.random());
	if(screen.height<hite || screen.width<wide){
		var props=window.open(path, i, 'scrollbars=1,toolabars=0,resizable=0,status=0,menubar=0,directories=0,location=0,height='+(hite+30)+', width='+(wide+30));
	}
	else{
		var props=window.open(path, i, 'scrollbars=1,toolabars=0,resizable=0,status=0,menubar=0,directories=0,location=0,height='+(hite+30)+', width='+(wide+30));
	}
	props.moveTo(windowX,windowY);
}


if(window.ActiveXObject) {
	try {
		var oHTTP = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch(e) {
		var oHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	}
} 
else {
	var oHTTP = new XMLHttpRequest();
}


/*******************************************************
For Check User Details
*******************************************************/


function checktel()
{
	document.forms['user_registration'].elements['abc'].value = 1;
}

function fetchState() {
	var country_id = document.getElementById('country_id').value;
	var mode = '';
	var hostName = 'www.chinesesym.com';
	var url = 'http://'+hostName+'/get_state.php';
	
	var pars = 'country_id='+country_id+'&mode='+mode;
	var myAjax = new Ajax.Request(
	url, 
		{
			method: 'get', 
			parameters: pars, 
			onComplete: stateFunction_Response
		});
}

function stateFunction_Response(originalRequest) {
	document.getElementById('state').innerHTML = originalRequest.responseText;
	document.getElementById('city').innerHTML = "<select name='city_id' class='look'><option value=''>Select</option></select>";	
}

function fetchCity() {
	var state_id = document.getElementById('state_id').value;
	var mode = '';
	var hostName = 'www.chinesesym.com';
	var url = 'http://'+hostName+'/get_city.php';

	var pars = 'state_id='+state_id+'&mode='+mode;
	var myAjax = new Ajax.Request(
	url, 
		{
			method: 'get', 
			parameters: pars, 
			onComplete: cityFunction_Response
		});
}

function cityFunction_Response(originalRequest) {
	document.getElementById('city').innerHTML = originalRequest.responseText;
}


function open_box(){
	//document.getElementById('display_login_box').style.display = '';
	document.getElementById('myfavouritsLogin').style.display = '';
	document.getElementById('favourites_login_form').style.display = '';
	document.getElementById('mailHeading').innerHTML = 'Login';
	document.getElementById('theLayer').style.visibility = 'visible';
}

function findPosX(obj){
	var curleft = 0;
	if(obj.offsetParent)
		while(1){
		  curleft += obj.offsetLeft;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj){
	var curtop = 0;
	if(obj.offsetParent)
		while(1){
		  curtop += obj.offsetTop;
		  if(!obj.offsetParent)
			break;
		  obj = obj.offsetParent;
		}
	else if(obj.y)
		curtop += obj.y;
	return curtop;
}
	function find_position(pos){
	var topPosition;
	topPosition = parseInt(findPosY(document.getElementById(pos)));
	leftPosition = parseInt(findPosX(document.getElementById(pos)));
	leftPosition = leftPosition;
	topPosition = topPosition+30;
	resizeDragBox(632, 600, topPosition, leftPosition);
	}
	
	function find_position1(pos){
	topPosition = parseInt(findPosY(document.getElementById(pos)));;
	leftPosition =parseInt(findPosX(document.getElementById(pos)));
	leftPosition = leftPosition;
	topPosition = topPosition+210;
	resizeDragBox(632, 600, topPosition, leftPosition);
	}
	

function resizeDragBox(boxWidth, titleBoxWidth, topPosition, leftPosition){
	document.getElementById('theLayer').style.top = parseInt(topPosition)+'px';
	document.getElementById('theLayer').style.left = parseInt(leftPosition)+'px';
}

function addToFavourite(loginId,venueId){
	returnUserfavourite(hostName+'/ajax_call.php?mode=favourite&loginUser='+loginId+'&venue='+venueId+'');
}
function returnUserfavourite(page) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			if (getValue=="done") {
				window.location = currentPage;
			}
		}
	}
	oHTTP.send(null);
}

function checksearch()
{
	if(document.article.search.value == "" )
	{
		document.article.search.focus();
		alert("Please type something for search in article");
		return false;
	}	
}

function checklogin()
{
	if(document.frmlogin.username.value == "e-mail" )
	{
		document.frmlogin.username.focus();
		alert("Please enter your Email Address");
		return false;
	}
	if(document.frmlogin.password.value == "password" )
	{
		document.frmlogin.password.focus();
		alert("Please enter your password");
		return false;
	}	
}


function box_inner_userLogin() 
{
	document.getElementById('user_email_inner_err').innerHTML = '';
	document.getElementById('user_pass_inner_err').innerHTML = '';
	var chk = 0;

	var userEmail = document.getElementById('user_email_inner').value;
	var userPass = document.getElementById('user_pass_inner').value;
	if(userEmail=="" )
	{
		alert('Please, enter login name');
		document.getElementById('user_email_inner').focus();
		chk++;
		return false;
	}
	if(userPass=="" )
	{
		alert('Please, enter password');
		document.getElementById('user_pass_inner').focus();
		chk++;
		return false;
	}
	if(chk == 0){
	document.getElementById('ajax_loader_mail').style.display = '';
	returnBoxInnerUserLogin(hostName+'/ajax_call.php?mode=user_login&userEmail='+userEmail+'&userPass='+userPass+'');
	
	}
}

function returnBoxInnerUserLogin(page, userLoginName) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			if (getValue=="done") {
				window.location = currentPage;
			}
			else {
				document.getElementById('ajax_loader_mail').style.display = 'none';
				document.getElementById('user_email_inner_err').innerHTML = 'Invalied Member ID or Password';
			}
		}
	}
	oHTTP.send(null);
}

function box_register_userLogin() 
{
	document.getElementById('user_email_inner_err').innerHTML = '';
	document.getElementById('user_pass_inner_err').innerHTML = '';
	var chk = 0;

	var userEmail = document.getElementById('user_email_inner').value;
	var userPass = document.getElementById('user_pass_inner').value;
	if(userEmail=="" )
	{
		alert('Please, enter login name');
		document.getElementById('user_email_inner').focus();
		chk++;
		return false;
	}
	if(userPass=="" )
	{
		alert('Please, enter password');
		document.getElementById('user_pass_inner').focus();
		chk++;
		return false;
	}
	if(chk == 0){
	document.getElementById('ajax_loader_mail').style.display = '';
	returnBoxRegisterUserLogin(hostName+'/ajax_call.php?mode=user_login&userEmail='+userEmail+'&userPass='+userPass+'');
	
	}
}

function returnBoxRegisterUserLogin(page, userLoginName) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			if (getValue=="done") {
				window.location = "index.php";
			}
			else {
				document.getElementById('ajax_loader_mail').style.display = 'none';
				document.getElementById('user_email_inner_err').innerHTML = 'Invalied Member ID or Password';
			}
		}
	}
	oHTTP.send(null);
}

function changeImageDisplay(imgPath, imgVal) 
{
	document.getElementById('mainImageDisplayPortion').innerHTML = '<a href="DOMAIN_PATH'+imgPath+'" rel="lightbox"><img src="DOMAIN_PATH/thumbnail.php?img=.'+imgPath+'&amp;width=410&amp;full=1" border="0" style="cursor: pointer;" /></a>';
}

function deleteConfirmRecord(path, toDelete){
	if(confirm('Are you sure to delete this '+toDelete+'?')){
		location.href=''+path+'';
	}
	else{
		return false;	
	}
}

function changeIconColor(ID){
	var $obj = document.getElementById(ID);
	$obj.className = 'menu_link_txt_hover';
}

function restoreIconColor(ID){
	var $obj = document.getElementById(ID);
	$obj.className = 'icon_box';
}
function changeIconColor1(ID){
	var $obj = document.getElementById(ID);
	$obj.className = 'menu_link_txt_hover1';
}

function restoreIconColor1(ID){
	var $obj = document.getElementById(ID);
	$obj.className = 'icon_box';
}

function request_form_check(){
	if(document.request_form.fname.value == "")
	{
		document.request_form.fname.focus();
		alert("Please enter First Name");
		return false;
	}
	
	if(document.request_form.lname.value == "")
	{
		document.request_form.lname.focus();
		alert("Please enter Last Name");
		return false;
	}
	
	if(document.request_form.email.value == "")
	{
		document.request_form.email.focus();
		alert("Please enter email Address");
		return false;
	}
	if(document.request_form.email.value != "")
	{
		var str=document.request_form.email.value ;
		
		var er=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if(!er.test(str))
		{
			document.request_form.email.focus();
			alert("Please enter your valied email address");
			return false;
		}
	} 
	if(document.request_form.booking_date.value == "")
	{
		document.request_form.booking_date.focus();
		alert("Please enter Booking Date");
		return false;
	}
	if(document.request_form.booking_request.value == "")
	{
		document.request_form.booking_request.focus();
		alert("Please enter Booking Rquest");
		return false;
	}
	if(document.request_form.requestcode.value == "")
	{
		document.request_form.requestcode.focus();
		alert("Please enter Code");
		return false;
	}
    
}
function contact_val()	{
		var errCounter = 0;
		var str = document.getElementById('newsemail').value;
		var er = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		
		if(document.getElementById('newsemail').value == "")	{
			document.getElementById('newsemail_err').innerHTML = "Email required.";
			errCounter++;
		}	else	{		
				if(!er.test(str))
				{
					errCounter++;
					document.getElementById('newsemail_err').innerHTML = "Enter valid Email Address";
				}	else	{
					document.getElementById('newsemail_err').innerHTML = "";
				}
				
		}
		if(errCounter == "0")	{
			document.newsletter.submit();
		}	else	{
			return false;
		}
	}



