
var hostName = 'http://www.food-worldwide.com';
var currentPage = '';

function onLoadCommonFunction() {
	//MM_preloadImages('http://www.food-worldwide.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 checkUserName(){
	if(document.forms['userRegistration'].elements['user_name'].value==""){
		document.getElementById('textContentHTML').innerHTML = 'Please enter user name.';
		document.getElementById('theLayer').style.visibility = 'visible';	
		return false;
	}
	var userLoginName = document.forms['userRegistration'].elements['user_name'].value;
	var firstName = document.forms['userRegistration'].elements['first_name'].value;
	var lastName = document.forms['userRegistration'].elements['last_name'].value;
	
	checkUser(hostName+'/ajax_call.php?mode=check_username&user_name='+userLoginName+'&first_name='+firstName+'&last_name='+lastName+'');
}

function checkUser(page) {
	oHTTP.open("POST", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			document.getElementById('textContentHTML').innerHTML = getValue;
			document.getElementById('theLayer').style.visibility = 'visible';
		}
	}
	oHTTP.send(null);
}


function changeUsernameValue(val){
	document.forms['userRegistration'].elements['user_name'].value = val;
	hideMe(); 
	return false;
}

function myfavourites_business(valID,msg){

		document.getElementById('myfavouritsLogin').style.display = '';
		document.getElementById('theLayer').style.visibility = 'visible';
		document.getElementById('special_msg').innerHTML = msg;	
		
	
}

function myfavourites_business1(valID){

		
		document.getElementById('myfavouritsLogin').style.display = 'none';
		document.getElementById('myfavouritsLogin1').style.display = '';
		document.getElementById('mailHeading').innerHTML = 'Resolution library';
		document.getElementById('theLayer').style.visibility = 'visible';	
		
	
}
function goTo(that)
{
  location.href=that;

}
function LoadNews()
{
	thisLocation = location.href;
	newsID = thisLocation.substring(thisLocation.lastIndexOf("?")+1,thisLocation.indexOf("#"));
	trID = "tr"+newsID;
	imgID = "img"+newsID;
	show(trID,imgID);
}

function changecategory(){
	if(document.getElementById('category').value == "Chef"){
		document.getElementById('chef_display').style.display = '';
		//document.getElementById('fck_display').reload(true);
		//fck_display.document.location.reload(true);
		//document.getElementById('fck_display').innerHTML = '{$biography}';
		//document.getElementById("biography___Frame").src=document.getElementById("biography___Frame").src; 
		//window.frames["biography__Frame"].location.reload(true);
		//biography__Frame.document.location.reload(true);
		//window.frames['biography__Frame'].location.reload(true);
		//window.frames['biography__Frame'].location.href = window.frames['biography__Frame'].location.href;
	} else { 
		document.getElementById('chef_display').style.display = 'none';
	}
}

function show_recipe(){
	document.getElementById('recipe').style.display = '';
	document.getElementById('article').style.display = 'none';
	document.getElementById('index_tab1').style.display = '';
	document.getElementById('index_tab2').style.display = 'none';
	
}

function show_article(){
	document.getElementById('recipe').style.display = 'none';
	document.getElementById('article').style.display = '';
	document.getElementById('index_tab1').style.display = 'none';
	document.getElementById('index_tab2').style.display = '';
}

function show_recipe_right(){
	document.getElementById('recipe_right').style.display = '';
	document.getElementById('article_right').style.display = 'none';
	document.getElementById('right_tab1').style.display = '';
	document.getElementById('right_tab2').style.display = 'none';
}

function show_article_article(){
	document.getElementById('recipe_right').style.display = 'none';
	document.getElementById('article_right').style.display = '';
	document.getElementById('right_tab1').style.display = 'none';
	document.getElementById('right_tab2').style.display = '';
}

function show_recipeDetails(){
	document.getElementById('r_details').style.display = '';
	document.getElementById('r_description').style.display = '';
	document.getElementById('r_photos').style.display = 'none';
	document.getElementById('ingred_tr').style.display = '';
	document.getElementById('ingred_button').style.display = '';
	document.getElementById('r_reviews').style.display = 'none';
	
	document.getElementById('recipe_tab1').style.display = '';
	document.getElementById('recipe_tab2').style.display = 'none';
	document.getElementById('recipe_tab3').style.display = 'none';
}

function show_recipePhotos(){
	document.getElementById('r_details').style.display = 'none';
	document.getElementById('r_description').style.display = 'none';
	document.getElementById('r_photos').style.display = '';
	document.getElementById('ingred_tr').style.display = 'none';
	document.getElementById('ingred_button').style.display = 'none';
	document.getElementById('r_reviews').style.display = 'none';
	
	document.getElementById('recipe_tab1').style.display = 'none';
	document.getElementById('recipe_tab2').style.display = '';
	document.getElementById('recipe_tab3').style.display = 'none';
}

function show_recipeReviews(){
	document.getElementById('r_details').style.display = 'none';
	document.getElementById('r_description').style.display = 'none';
	document.getElementById('r_photos').style.display = 'none';
	document.getElementById('ingred_tr').style.display = 'none';
	document.getElementById('ingred_button').style.display = 'none';
	document.getElementById('r_reviews').style.display = '';
	
	document.getElementById('recipe_tab1').style.display = 'none';
	document.getElementById('recipe_tab2').style.display = 'none';
	document.getElementById('recipe_tab3').style.display = '';
}
function show_articleDetails(){
	document.getElementById('article_tab1').style.display = '';
	document.getElementById('article_tab2').style.display = 'none';
	document.getElementById('article_description').style.display = '';
	document.getElementById('article_review').style.display = 'none';
}
function show_articleReviews(){
	document.getElementById('article_tab1').style.display = 'none';
	document.getElementById('article_tab2').style.display = '';
	document.getElementById('article_description').style.display = 'none';
	document.getElementById('article_review').style.display = '';
}
function show_usa_ingredient(){
	//document.getElementById('main_ingredient').style.display = 'none';
	document.getElementById('ingredientUSA').style.display = '';
	document.getElementById('ingredientUK').style.display = 'none';
}

function show_metric_ingredient(){
	//document.getElementById('main_ingredient').style.display = 'none';
	document.getElementById('ingredientUSA').style.display = 'none';
	document.getElementById('ingredientUK').style.display = '';
}


function userLogin() {
	document.getElementById('user_name_err').innerHTML = '';
	var chk = 0;

	var userName = document.forms['loginform'].elements['username'].value;
	var userPass = document.forms['loginform'].elements['password'].value;
	var rememberme;
	if(document.getElementById('remember_me').checked) {
		rememberme = 1;
	} else {
		rememberme = 0;
	}
	
	if(userName=="" || userName=="User Name"){
		alert('Please, enter login name');
		document.getElementById('username').focus();
		chk++;
		return false;
	}
	if(userPass=="" || userPass=="Password"){
		alert('Please, enter password');
		document.getElementById('password').focus();
		chk++;
		return false;
	}
	if(chk == 0){
		document.getElementById('user_login_form_portion').style.display = 'none';
		document.getElementById('user_login_loader_portion').style.display = '';

		returnUserLogin(hostName+'/ajax_call.php?mode=user_login&userName='+userName+'&userPass='+userPass+'&rememberme='+rememberme+'');
	} else {
		return false;
	}
}

function returnUserLogin(page) {
	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('user_login_form_portion').style.display = '';
				document.getElementById('user_login_loader_portion').style.display = 'none';
				document.getElementById('user_name_err').innerHTML = 'Invalied User Name or Password';
			}
		}
	}
	oHTTP.send(null);
}

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 resizeDragBox(boxWidth, titleBoxWidth, topPosition, leftPosition){
	document.getElementById('theLayer').style.top = parseInt(topPosition)+'px';
	document.getElementById('theLayer').style.left = parseInt(leftPosition)+'px';
}

function open_box(){
	document.getElementById('myfavouritsLogin').style.display = '';
	document.getElementById('theLayer').style.visibility = 'visible';	
}

function find_position_new(pos){
	var topPosition;
	topPosition = parseInt(findPosY(document.getElementById(pos)));
	leftPosition = parseInt(findPosX(document.getElementById(pos)));
	leftPosition = leftPosition;
	topPosition = topPosition+20;
	resizeDragBoxNew(632, 600, topPosition, leftPosition);
}
function resizeDragBoxNew(boxWidth, titleBoxWidth, topPosition, leftPosition){
	document.getElementById('theLayer_new').style.top = parseInt(topPosition)+'px';
	document.getElementById('theLayer_new').style.left = parseInt(leftPosition)+'px';
}

function open_box_new(){
	document.getElementById('theLayer_new').style.visibility = 'visible';	
}
function hideMe_new(){
	document.getElementById('theLayer_new').style.visibility = 'hidden';	
}
function hideMe_messagebox(){
	document.getElementById('alert_popup').style.visibility = 'hidden';	
}

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

/**************************************************************************************/

function relocateMsgBox(msgBoxID, posRefID) {
	//alert(msgBoxID);
	var topPosition = parseInt(findPosY(document.getElementById(posRefID)));
	var leftPosition = parseInt(findPosX(document.getElementById(posRefID)));
	

	document.getElementById(msgBoxID).style.top = (parseInt(topPosition) + 150)+'px';
	document.getElementById(msgBoxID).style.left = (parseInt(leftPosition) + 180)+'px';
	
	document.getElementById(msgBoxID).style.visibility = 'visible';
	//globalMsgID = msgBoxID;
	//closeMsgPopUp();
}

/**************************************************************************/

function changeStatus(changeMode, ID, statusPortion){
	if(changeMode!="" && ID!="" && statusPortion!=""){
		document.getElementById(statusPortion).innerHTML = '<img src="'+hostName+'/admin_images/loader.gif" align="absmiddle" alt="Loader" border="0" title="Please Wait" class="changeStatus" />';
		changeStatusResponse(hostName+'/admin/admin_change_status.php?mode='+changeMode+'&id='+ID+'', changeMode, ID, statusPortion);
	}
}

function changeStatusResponse(page, changeMode, ID, statusPortion) {
	oHTTP.open("GET", page, true);
	oHTTP.onreadystatechange=function() {
		if (oHTTP.readyState==4) {
			var getValue=oHTTP.responseText;
			if (getValue=="none") {
				document.getElementById(statusPortion).innerHTML = '<img src="'+hostName+'/admin_images/icon_inactive.gif" align="absmiddle" alt="Inactive" border="0" onclick="javascript: changeStatus(\''+changeMode+'\', '+ID+', \''+statusPortion+'\');" title="Change Status" class="changeStatus" />';
			}
			else{
				document.getElementById(statusPortion).innerHTML = '<img src="'+hostName+'/admin_images/icon_active.gif" align="absmiddle" alt="Active" border="0" onclick="javascript: changeStatus(\''+changeMode+'\', '+ID+', \''+statusPortion+'\');" title="Change Status" class="changeStatus" />';
			}
		}
	}
	oHTTP.send(null);
}

function addToFavourite(userid,recipeid){
	returnUserfavourite(hostName+'/ajax_call.php?mode=favourite&user='+userid+'&recipe='+recipeid+'');
}

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;
				//window.location = page;
			}
		}
	}
	oHTTP.send(null);
}

function bookmarksite(urlAddress,pageName) {
	alert(urlAddress);
	alert(pageName);
	if (window.external) { 
	window.external.AddFavorite(urlAddress,pageName);
	} 
	else { 
	alert("Sorry! Your browser doesn't support this function."); 
	} 
}

function open_tr(id){
	if(document.getElementById('answer_'+id).style.display == 'none'){
		document.getElementById('answer_'+id).style.display = '';
	} else {
		document.getElementById('answer_'+id).style.display = 'none';
	}
}

function createBokkmarPage(title, url) {
	if ( navigator.appName != 'Microsoft Internet Explorer' ) {
		window.sidebar.addPanel(title, url, "");
	}
	else {
		window.external.AddFavorite(url, title);
	}
}