function showpopop1(msg,boxWidth,boxHeight){
	var bodyObj = document.getElementsByTagName('body')[0];
	var alertObj = document.createElement('div');
	alertObj.id = 'alert';
	alertObj.style.position = 'absolute';
	alertObj.style.width = bodyObj.offsetWidth + 'px';
	alertObj.style.height = bodyObj.offsetHeight + 'px';
	alertObj.style.left = '0';
	alertObj.style.top = '0';
	alertObj.style.border = '1px solid #ff0000';

	var alertBgObj = document.createElement('div');	
	alertBgObj.style.position = 'absolute';
	alertBgObj.style.zIndex = '4';
	alertBgObj.style.width = bodyObj.offsetWidth + 'px';
	alertBgObj.style.height = bodyObj.offsetHeight + 'px';
	
	alertObj.appendChild(alertBgObj);
	bodyObj.appendChild(alertObj);
	
	var screenHt = (screen.availHeight) ? screen.availHeight : window.screen.availHeight;
	var scrollTop = window.pageYOffset;
	//var scrollTop = 0;
	scrollTop = (isNaN(scrollTop)) ? bodyObj.scrollTop : scrollTop;
		
	var content = '<div>&nbsp;<div>'+ msg;
	var mLeft = (bodyObj.offsetWidth - boxWidth - 100) / 2;
	var mTop = ((screenHt - boxHeight - 100)/2) + scrollTop;
	
	var popDiv =  buildBox(content, boxWidth, boxHeight, mLeft, mTop);	
	popDiv.style.left = '0';
	popDiv.style.top = '0';		
	alertObj.appendChild(popDiv);
}

function buildBox(content, width, height, mLeft, mTop, closeAction){
	
	
	var popDiv = document.createElement('div');
	var divWidth = '1';
	popDiv.style.width = divWidth + 'px';
	popDiv.id = 'popup'
	popDiv.style.background = '#ffffff';
// 	
// 	var popTbl = document.createElement('div');
// 	popDiv.appendChild(popTbl);
// 	popTbl.id = 'popTbl';
// 	popTbl.border = '0';	
// 	popTbl.style.position = 'absolute';
// 	popTbl.style.marginLeft = mLeft + 'px';
// 	popTbl.style.marginTop = mTop + 'px';
// 	popTbl.style.zIndex = 23;	
// 	popTbl.style.width = width + 'px';
// 	popTbl.style.height = height + 'px';
// 	popTbl.style.background = '#ffffff';
	
	
	var bodyObj = document.getElementsByTagName('body')[0];
								
	var popObj = document.getElementById('popbox');
	alert(popObj);
	popObj.style.visibility = 'visible';
	popObj.style.display = 'block';
	popObj.style.position = 'absolute';
	popObj.style.left = bodyObj.style.left + 220 + 'px';
	popObj.style.top = bodyObj.style.top + 12 + 'px';
	popObj.style.zIndex = '5';
	
	popDiv.appendChild(popObj);
	
	return popDiv;
}

function showpopop(msg,boxWidth,boxHeight){
	var popObj = document.getElementById('popbox');	
	var bodyObj = document.getElementsByTagName('body')[0];
	var popboxLeft = document.getElementById('pTourPopboxLeft');
	var popboxRight = document.getElementById('pTourPopboxRight');
	popboxLeft.style.height = boxHeight+'px';
	popboxRight.style.height = boxHeight + 'px';
	popObj.style.visibility = 'visible';
	popObj.style.display = 'block';	
	popObj.style.position = 'absolute';	
	popObj.style.left = bodyObj.style.left + 220 + 'px';
	popObj.style.top = bodyObj.style.top + 140 + 'px';
	popObj.style.zIndex = '5';	
	document.getElementById('swfDiv').className = 'hiddendiv';
	document.getElementById('emailFriend').className = 'visiblediv';
	document.getElementById('emailFriendAfter').className = 'hiddendiv';
	// hide if shown the share, copy link
	var shareObj = document.getElementById('sharebtn');
	if (shareObj){
		shareObj.className = 'hiddendiv';
	}	
	var copyObj = document.getElementById('copyLink');
	if (copyObj){
		copyObj.className = 'hiddendiv';
	}	
	
}

function getVars(){
	this.fieldN = new Array();	// Field name
	this.fieldT = new Array();	// Field type (text, editor, checkbox, radio, select, mselect, date)
}

var objVar = new getVars();
objVar.fieldN[0] = "my_name";
objVar.fieldT[0] = "text";

objVar.fieldN[1] = "my_email";
objVar.fieldT[1] = "text";

objVar.fieldN[2] = "friends_name";
objVar.fieldT[2] = "text";

objVar.fieldN[3] = "friends_email";
objVar.fieldT[3] = "text";

function validateForm(formN){
	var frmObj = eval("document." + formN);
	
	var errFldsCntr = 0;
	
	document.getElementById('errorEmail').className = 'hiddendiv';
	
	for(var i=0; i< objVar.fieldN.length; i++){
		if(objVar.fieldT[i] == "text"){
			var frmElm = eval("frmObj." + objVar.fieldN[i]);
			
			if((frmElm.value == "") || (frmElm.value == " ")) {
				frmElm.className = 'textBoxRed';
				
				var frmElmLabel = frmElm.parentNode.previousSibling;
				frmElmLabel.className =	frmElmLabel.className.replace('black','red');				
				errFldsCntr++
			}else if(objVar.fieldN[i].indexOf("email") >= 0){
				if(!checkEmail(frmElm.value)) {
					frmElm.className = 'textBoxRed';
					var frmElmLabel = frmElm.parentNode.previousSibling;
					frmElmLabel.className =	frmElmLabel.className.replace('black','red');		
					document.getElementById('errorEmail').className = 'red visiblediv';
					errFldsCntr++
				}else{
					frmElm.className = 'textBox';
					var frmElmLabel = frmElm.parentNode.previousSibling;
					frmElmLabel.className =	frmElmLabel.className.replace('red','black');	
				}
			}else{
				frmElm.className = 'textBox';
				var frmElmLabel = frmElm.parentNode.previousSibling;
				frmElmLabel.className =	frmElmLabel.className.replace('red','black');					
			}			
		}
	}
	
	if (errFldsCntr > 0){
		document.getElementById('error').className = 'red visiblediv';		
	}else{
		document.getElementById('error').className = 'hiddendiv';	
		sendMail();	
	}	
	return false;
	
}

function checkEmail(fieldValue){
	var chkAt = fieldValue.indexOf("@");
	var chkDot= fieldValue.indexOf(".");
	var chkHack= fieldValue.indexOf("@.");
	var chkHackA= fieldValue.indexOf(".@");

	if((chkAt >= 0) && (chkDot >= 0) && (chkHack == -1) && (chkHackA == -1) ) {
		return true;
	}
	return false;
}

function sendMail(){
	document.getElementById('emailFriend').className = 'hiddendiv';
	
	var ajaxVar = new ajaxVars();			
	ajaxVar.vars['action'] = "runFunction";
	ajaxVar.vars['func'] = "tell_friend";		
	ajaxVar.vars['my_name'] = document.getElementById('my_name').value;				
	ajaxVar.vars['my_email'] = document.getElementById('my_email').value;				
	ajaxVar.vars['friends_name'] = document.getElementById('friends_name').value;
	ajaxVar.vars['friends_email'] = document.getElementById('friends_email').value;	
 	ajaxVar.vars['comments'] = document.getElementById('comments').value;
 	ajaxVar.vars['productname'] = document.getElementById('productname').value; 	
 	ajaxVar.vars['productGenname'] = document.getElementById('productGenName').value; 	
 	ajaxVar.vars['productId'] = document.getElementById('productId').value; 	 	
 	ajaxVar.vars['productCatId'] = document.getElementById('pcatId').value;
 	ajaxVar.vars['productVariantId'] = document.getElementById('pvariantId').value;
 	ajaxVar.vars['productSubCatId'] = document.getElementById('psubcatId').value; 	
 	ajaxVar.vars['lang_id'] = document.getElementById('langId').value; 	
 	
	ajaxVar.gotoFunction = 'returnData';
	ajaxVar.phpFile = "../includes/ajax.files.php";					
	ajaxVar.AjaxPostSQL();			
	return false;
}

function returnData(data){	
	document.getElementById('emailFriendAfter').className = 'visiblediv';
	document.getElementById('message').innerHTML = data;		
	return false;
}


function openPopUpTourFile(genId,typeImg,heightImg){
	var popObj = document.getElementById('popbox');
	popObj.style.visibility = 'visible';
	popObj.style.display = 'block';
	var popboxLeft = document.getElementById('pTourPopboxLeft');
	var popboxRight = document.getElementById('pTourPopboxRight');
	popboxLeft.style.height = '730px';
	popboxRight.style.height = '730px';	
	var bodyObj = document.getElementsByTagName('body')[0];								
	var popObj = document.getElementById('popbox');
	popObj.style.position = 'absolute';
	popObj.style.left = bodyObj.style.left + 220 + 'px';
	popObj.style.top = bodyObj.style.top + 12 + 'px';
	popObj.style.zIndex = '5';	
	document.getElementById('swfDiv').className = 'visiblediv';
	document.getElementById('emailFriend').className = 'hiddendiv';
	document.getElementById('emailFriendAfter').className = 'hiddendiv';	
	var swfdivObj = document.getElementById('swfDiv');
	if (typeImg == 'gif'){
		var flash_content = "<img src=\"../swfs/"+ genId + "."+ typeImg +"\" alt=\"\"  />";
		popboxLeft.style.height = heightImg + 'px';		
		popboxRight.style.height = heightImg +  'px';
		// un-hide if shown the share button.
		var shareObj = document.getElementById('sharebtn');
		if (shareObj){
			shareObj.className = 'visiblediv';							
		}	
		var copyObj = document.getElementById('copyLink');
		if (copyObj){
			copyObj.className = 'visiblediv';
		}	
	}else if (typeImg == 'inlineframeflash'){
		var flash_content;
		flash_content = "<iframe src='../swfs/show_flash.php?part_number="+ genId +"' height='550' width='580' frameborder=0 >";		
		flash_content += "</iframe>";
		popboxLeft.style.height = '660px';
		popboxRight.style.height = '660px';	
		// un-hide if shown the share button.
		var shareObj = document.getElementById('sharebtn');
		if (shareObj){
			shareObj.className = 'visiblediv';							
		}
		var copyObj = document.getElementById('copyLink');
		if (copyObj){
			copyObj.className = 'visiblediv';
		}	
	}else{
		var flash_content = loadSWF(genId);	
	}		
	swfdivObj.innerHTML = "<img src=\"../images/pTourLoader.gif\" alt=\"\"  />";
	
	flash_content += "";
	flash_content += '<table border="0" cellpadding="0" cellspacing="0" width="600" style="margin-top:10px;" align="center" >';
	flash_content += '<tr><td colspan="2" style="border-top:1px solid #efefef;margin-bottom:10px;" >&nbsp;</td></tr>';
	flash_content += '<tr>';
		flash_content += '<td ><a href="http://www.verbatim-europe.com" target="_blank" ><img src="../images/verbatim_email.jpg" alt="Verbatim Europe - Technology you can trust" title="Verbatim Europe - Technology you can trust" border="0" /></a></td>';
		flash_content += '<td align="right" width="100%">Powered by <a href="http://www.orckid.com" target="_blank" >Orckid Digital</a>  Copyright ';		
		var d = new Date();
		flash_content += d.getFullYear();
		flash_content += ' Verbatim Ltd. All Rights Reserved. <a href="http://www.verbatim-europe.com" target="_blank" >www.verbatim-europe.com</a></td>';
	flash_content += '</tr>';
	flash_content += '</table>';
	
	swfdivObj.innerHTML = flash_content;
}

function showGreenPopup(msg,boxWidth,boxHeight,divId){
	var popObj = document.getElementById('popbox');	
	var bodyObj = document.getElementsByTagName('body')[0];
	var popboxLeft = document.getElementById('pTourPopboxLeft');
	var popboxRight = document.getElementById('pTourPopboxRight');
	popboxLeft.style.height = boxHeight+'px';
	popboxRight.style.height = boxHeight + 'px';
	popObj.style.visibility = 'visible';
	popObj.style.display = 'block';	
	popObj.style.position = 'absolute';	
	popObj.style.left = bodyObj.style.left + 220 + 'px';
	popObj.style.top = bodyObj.style.top + 140 + 'px';
	popObj.style.zIndex = '5';	
	var midObj =  document.getElementById('swfDiv');
	if (midObj){
		midObj.className = 'visiblediv';
		if (divId){
			var conDiv = document.getElementById(divId);
		}else{
			var conDiv = document.getElementById('green_popup');
		}
		midObj.innerHTML = conDiv.innerHTML;	
		midObj.style.textAlign = 'left';		
		midObj.style.width = '590px';
		popboxLeft.style.height = midObj.offsetHeight + 27 + 'px';
		popboxRight.style.height = popboxLeft.style.height;
	}
	document.getElementById('emailFriend').className = 'hiddendiv';
	document.getElementById('emailFriendAfter').className = 'hiddendiv';
	// hide if shown the share, copy link
	var shareObj = document.getElementById('sharebtn');
	if (shareObj){
		shareObj.className = 'hiddendiv';
	}	
	var copyObj = document.getElementById('copyLink');
	if (copyObj){
		copyObj.className = 'hiddendiv';
	}	
}

function savePageLike(prod_id,langid){
	var ajaxVar = new ajaxVars();
	ajaxVar.vars['action'] = "runFunction";
	ajaxVar.vars['func'] = "page_like";					
	ajaxVar.vars['general_id'] = prod_id;
	ajaxVar.vars['lang_id'] = langid;
	var prodNm = document.getElementById('productname');
	if (prodNm){
		ajaxVar.vars['product_name'] = prodNm.value;
	}
	ajaxVar.gotoFunction = 'display_like_count';			
	ajaxVar.phpFile = "../includes/ajax.files.php";				
	ajaxVar.AjaxPostSQL();	
}

function display_like_count(msg){
	var likeObj = document.getElementById('likediv');
	if (likeObj){
		likeObj.innerHTML = msg;
	}
}

function ShowHideRightBox(boxId,totalBoxes,imgId){
	if (totalBoxes){
		var divObj = document.getElementById(boxId);
		var imgObj = document.getElementById(imgId);	
		if (divObj){
			if (divObj.className.indexOf('hiddendiv') > 0){				
				divObj.className = divObj.className.replace("hiddendiv","visiblediv");
				if (imgObj){
					imgObj.src = imgObj.src.replace('right_plus.gif','right_minus.gif');					
				}		
			}else{					
				divObj.className = divObj.className.replace("visiblediv","hiddendiv");
				if (imgObj){
					imgObj.src = imgObj.src.replace('right_minus.gif','right_plus.gif');
				}		
			}
		}
	}
}

var _CLICKED_TAB = 1;

function openTab(tabNm,tabNo){
	if (_CLICKED_TAB != tabNo)  {
		animatedcollapse.toggle(tabNm);
		showTab(tabNo);	
	}	
	_CLICKED_TAB = tabNo;
}

