
var hostName = 'http://www.tan-talising.co.uk';
var currentPage = '';

function onLoadCommonFunction() {
	//MM_preloadImages('http://www.tan-talising.co.uk/admin_images/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.tan-talising.co.uk';
	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.tan-talising.co.uk';
	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="http://www.tan-talising.co.uk'+imgPath+'" rel="lightbox"><img src="http://www.tan-talising.co.uk/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 newsletter_check(){
	if(document.newsletter.name.value == "")
	{
		document.newsletter.name.focus();
		alert("Please enter Name");
		return false;
	}
	
	if(document.newsletter.newsemail.value == "")
	{
		document.newsletter.newsemail.focus();
		alert("Please enter email Address");
		return false;
	}
	if(document.newsletter.newsemail.value != "")
	{
		var str=document.newsletter.newsemail.value ;
		
		var er=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
		if(!er.test(str))
		{
			document.newsletter.newsemail.focus();
			alert("Please enter your valid email address");
			return false;
		}
	} 
    
}



