
var hostName = 'http://intimateweddings.com';
var currentPage = '';

function onLoadCommonFunction() {
	//MM_preloadImages('http://intimateweddings.com/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 = 'intimateweddings.com';
	var url = ''+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' style='width:120px;'><option value=''>Select</option></select>";	
}

function fetchCity() {
	var state_id = document.getElementById('state_id').value;
	var mode = '';
	//var hostName = 'intimateweddings.com';
	var url = ''+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+30;
	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 addToFavouritearticle(articleloginId,articleId){
returnUserarticlefavourite(hostName+'/ajax_call.php?mode=Articlefavourite&adminloginUser='+articleloginId+'&article='+articleId+'');
}
function returnUserarticlefavourite(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 addToFavouritereview(reviewloginId,reviewId){
returnUserreviewfavourite(hostName+'/ajax_call.php?mode=Reviewfavourite&adminloginUser='+reviewloginId+'&review='+reviewId+'');
}
function returnUserreviewfavourite(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 checkgoogle()
{
	if(document.frm_src.country_id.value == "" )
	{
		document.frm_src.country_id.focus();
		alert("Please select Country");
		return false;
	}
	if(document.frm_src.state_id.value == "" )
	{
		document.frm_src.state_id.focus();
		alert("Please select State");
		return false;
	}
	else
	{
		var country_id = document.frm_src.country_id.options[document.frm_src.country_id.selectedIndex].value;
		var state_id = document.frm_src.state_id.options[document.frm_src.state_id.selectedIndex].value;
		var city_id = document.frm_src.city_id.options[document.frm_src.city_id.selectedIndex].value;
		var venue_type_id = document.frm_src.venue_type_id.options[document.frm_src.venue_type_id.selectedIndex].value;
		
		window.location.href="googlemap.php?mode=veneu_search&country_id="+country_id+"&state_id="+state_id+"&city_id="+city_id+"&venue_type_id="+venue_type_id;
		
		
	}
}

function checkGoogleMap()
{
	if(document.frm_src.country_id.value == "" )
	{
		document.frm_src.country_id.focus();
		alert("Please select Country");
		return false;
	}
	if(document.frm_src.state_id.value == "" )
	{
		document.frm_src.state_id.focus();
		alert("Please select State");
		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 = "venuemanager.php";
			}
			else {
				document.getElementById('ajax_loader_mail').style.display = 'none';
				document.getElementById('user_email_inner_err').innerHTML = 'Invalid Member ID or Password';
			}
		}
	}
	oHTTP.send(null);
}

function changeImageDisplay(imgPath, imgVal) 
{
	document.getElementById('mainImageDisplayPortion').innerHTML = '<img src="http://intimateweddings.com/phpThumb/phpThumb.php?src='+imgPath+'&w=410&h=410" border="0" style="cursor: normal;" />';
}

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