//all javascripts that are SITE SPECIFIC, and probably cannot be reused in other site, go in this file

var appleDevice=0;
//alert('site.js up');

//TLC media play function
function tlcmp(vFile,vTitle,vWidth,vHeight,isHD,posterImg){
	if(posterImg==null){posterImg="";}
	//alert('in mp, Shadowbox='+Shadowbox);
	if(vTitle==null){vTitle="";}
	//if video height and/or width were not sent, use the default values for SD and HD content
	if(vWidth==null||vWidth==0){vWidth=isHD==1?640:480;}
	if(vHeight==null||vHeight==0){vHeight=360;}
	//add the standard video filepath to the vFile variable if it does not already have a path included
	if(vFile.indexOf('/')==-1){vFile='/_uploads/videos/_source/'+vFile;}
	//create a direct link to the video file if this is an apple mobile device
	if(appleDevice==1){
		$.get("/_libs/media_embed.php?",{'enc':vFile},function(data){top.location.href='/_libs/media_embed.php?dp='+data;});
		return;
	}else{
		Shadowbox.open({player:'flv',title:vTitle,content:vFile,height:vHeight,width:vWidth});
	}
}


//var curCat=null;
function updatePageSetup(area){
	//first update the header images
	pathPrefix=getPathPrefix(area,1);
	framePrefix=getPathPrefix(area,0);
	assocImgString="";
	allImages=framePrefix.frames['iframeHeaderImages'].document.getElementsByTagName('input');
	for(i=0;i<allImages.length;i++){
		if(allImages[i].checked){
			//tilda separate values
			if(assocImgString!=""){assocImgString+="~";}
			assocImgString+=allImages[i].name;
		}
	}
	//alert(assocImgString);
	pathPrefix.tableForm.db__headerImages.value=assocImgString;
	//next update the sidelinks
	assocLinkString="";
	allILinks=framePrefix.frames['iframeSidelinks'].document.getElementsByTagName('input');
	for(i=0;i<allILinks.length;i++){
		if(allILinks[i].checked){
			//tilda separate values
			if(assocLinkString!=""){assocLinkString+="~";}
			assocLinkString+=allILinks[i].name;
		}
	}
	//alert(assocLinkString);
	pathPrefix.tableForm.db__sidelinks.value=assocLinkString;
	return true;
}

function cabinResetConfirm(){
	decision=confirm('Are you sure you want to reset all cabin updates?');
	if(decision){
		document.tableForm.cabinReset.value=1;
		document.tableForm.submit();
	}
}

/*function swapProdImg(objName){
	//alert('in swapProdImg');
	srcImgObj=findObjectPath(objName);
	//alert(srcImgObj.src);
	ajaxCall('/_libs/image_output.php?output=screenPath&src='+stringReplace(srcImgObj.src,'thumb','_source'),'GET','','updateProdImg');
}

function showProdPop(objName,prodID){
	//alert('in showProdPop');
	//POPOBJ IS NOW SET ONLY ONCE IN THE GALLERY PAGE ITSELF
	//popObj=findObjectPath('prodPopDiv');
	srcImgObj=findObjectPath(objName);
	srcTxtObj=findObjectPath(objName+'_txt');
	popObj.innerHTML=' <img name="prodPopImg" id="prodPopImg" src="/_images/shared/spacer.gif" width="250" height="168" /><p class="pPopText"><nobr>'+srcTxtObj.innerHTML+'</nobr></p>';
	ajaxCall('/_libs/image_output.php?output=printPath&outputFolder=thumbPop&maxW=250&maxH=168&quality=65&src='+stringReplace(srcImgObj.src,'thumb','_source'),'GET','','showPopImg');
	//ajaxCall('/goods/galleryPop.php?prodID='+prodID,'GET','','showPopImg');
}*/

/*AJAX functions*/
function ajaxStart(){
	/*//alert('in ajaxProcess');
	doneCall=String(ajaxDoneCalls.slice(0,1));
	//alert('doneCall='+doneCall);
	switch(doneCall){
		case "showPopImg":
			//alert('ajaxstart - show pop img');
			//popImgObj=findObjectPath('prodPopImg');
			//popImgObj.src='/_images/shared/loading2.gif';
		break;
	}*/
}

function ajaxProcess(){}

function ajaxDone(){
	//alert('in ajaxDone');
	//alert(xmlHttp.responseText);
	doneCall=ajaxDoneCalls.shift();
	//alert('doneCall='+doneCall);
	switch(doneCall){
		case 'showPopImg':
		if(xmlHttp.responseText!=null && xmlHttp.responseText!=""){
			//popObj.innerHTML=xmlHttp.responseText;
			popImgObj=findObjectPath('prodPopImg');
			popImgObj.src=xmlHttp.responseText;
		}
		break;
		case 'updateProdImg':
			if(xmlHttp.responseText==null || xmlHttp.responseText==""){
				ajaxCall('/_libs/image_output.php?output=screenPath&src='+stringReplace(srcImgObj.src,'thumb','_source'),'GET','','updateProdImg');
			}
			//alert(xmlHttp.responseText);
			prodImgObj=findObjectPath('lgProdImg');
			prodImgObj.src=xmlHttp.responseText;
		break;
	}
}








