// display decision alert box
function decision(message, url){
	if(confirm(message)) location.href = url;
}

// open browser window
function openPopUp(url, windowName, w, h, resizable) {

           var winl = (screen.width - w) / 3;
           var wint = (screen.height - h) / 3;
           winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',resizable='+resizable ;
		var win = window.open(url, windowName, winprops);
           if (parseInt(navigator.appVersion) >= 4) { 
              	win.window.focus(); 
           } 
}


var newWin;
function popupWin(sel_img, winfeats){
var winURL = 'gallery/beaches.php?imgToDisplay=' + sel_img;
newWin = window.open(winURL, 'gallery', winfeats);
setTimeout('newWin.focus();',250); 
}
var newFanmail;
function popupFanmail(winURL, winfeats){
newFanmail = window.open(winURL, 'fanmail', winfeats);
setTimeout('newWin.focus();',250);
}
function jumpMenu(target,object,restore){ 
  eval(target+".location='"+object.options[object.selectedIndex].value+"'");
  if (restore) object.selectedIndex=0;
}

function findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function getImage(imageName)
{
		findObj('img').src = imageName;
}

function submitDoc(formName) { 
  var obj;
 
	if (obj=findObj(formName)!=null) 
	{
		findObj(formName).submit(); 
	}
	else 
	{
		alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');
	}

}

function submitOrder(formName,garment,productID) { 
  var obj;
 
	if (obj=findObj(formName)!=null) 
	{
	if(productID!=25 && productID!=30){
		if(Colouridx==0 || Sizeidx==0){
			alert('Please select all options');
			exit;
	}else{
		alert(orderQty + '  ' +garment+' added to cart');
		}
	}else{
      alert(orderQty + '  ' +garment+' added to cart');
      }
	findObj(formName).submit(); 
	}
	else 
	{
		alert('The form you are attempting to submit called \'' + formName + '\' couldn\'t be found. Please make sure the submitDoc function has the correct id and name.');
	}

}

function PopUp(urlToOpen) {
		var win = window.open(urlToOpen, 'sizeinfo', 'width=400 height=400 resizable=1');
           win.focus(); 
}
function Display(id, str) {
	var element = document.getElementById(id);
	element.innerHTML = str;
	return;
}

function changeVisibility()
{
var browser=navigator.appName;
if (browser=="Microsoft Internet Explorer"){
  document.getElementById("r1").style.display="block";
  }else{
  document.getElementById("r1").style.display="table-row";
  }

}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}













function wallpaper_centeropen(winwidth, winheight, num){
	var mystring="wallpaper_view.php?num="+num;
	var centerwin=window.open(mystring,"window_varify", "toolbar=0, resize=1, scrollbars=1, status=0, menubar=0")
	centerwin.resizeTo(screen.width/1.4, screen.height/1.2)
	centerwin.moveTo(screen.width/2-winwidth/2, screen.height/2-winheight/2) //center window on user's screen
}
function vvmodels_centeropen(winwidth, winheight, num, model){
	var mystring="vvmodels_view.php?num="+num+"&model="+model;
	var centerwin=window.open(mystring,"window_varify", "toolbar=0, resize=1, scrollbars=1, status=0, menubar=0")
	centerwin.resizeTo(screen.width/1.4, screen.height/1.2)
	centerwin.moveTo(screen.width/2-winwidth/2, screen.height/2-winheight/2) //center window on user's screen
}















var arr=new Array('img1','img2','img3', 'img4', 'img5');
var arr1=new Array();
  //set the number of menu
 var cnt=5;
 var tt;
Array.prototype.inArray = function (value)
{
// Returns true if the passed value is found in the
// array. Returns false if it is not.
var i;
for (i=0; i < this.length; i++)
{
        if (this[i] == value)
        {
        return true;
        }
}
return false;
};
function Show(Click_Menu)
{
    tt=Click_Menu.id;
    for(i=1;i<=cnt;i++)
    {
        var tmp="display"+i;
        if(tmp==tt)
        {
           if(Click_Menu.style.display=="none")
           {
              Click_Menu.style.display="inline";
           }
        }
        else
        {
            document.getElementById(tmp).style.display ="none";
        }
    }
}
function disp()
{
    document.getElementById('display1').style.display="inline";
    document.getElementById('display2').style.display="none";
    document.getElementById('display3').style.display="none";
	document.getElementById('display4').style.display="none";
	document.getElementById('display5').style.display="none";
}

	var offsetfrommouse=[50,-25]; //image x,y offsets from cursor position in pixels. Enter 0,0 for no offset 50,-25 default
	var displayduration=0; //duration in seconds image should remain visible. 0 for always.
	var currentimageheight = 490; // maximum image size.
	var previewwidth = currentimageheight - 15;
	var prev_h;
	var prev_w;

	function showprev(imagesrc, w, h){

			prev_h = h;
			prev_w = w;

			newHTML = '<div style="padding: 5px; background-color: #FFF; border: 1px solid #888; width: ' + previewwidth + 'px;">';
			newHTML = newHTML + '<div align="center" style="padding: 8px 2px 8px 2px;"><img src="' + imagesrc + '" border="0"></div>';
			newHTML = newHTML + '</div>';

			getprevobjnostyle("previewcontainer").innerHTML = newHTML;
			setTimeout('getprevobj("previewcontainer").visibility="visible"',200);
			document.onmousemove=followmouse;
		}

	function followmouse(e){

		var xcoord=offsetfrommouse[0]
		var ycoord=offsetfrommouse[1]
		var dragging = 0

			//var x = e.pageX != undefined ? e.pageX : event.clientX
			//var y = e.pageY != undefined ? e.pageY : event.clientY

		var flip_loc_x = 550 // When we get to loc clientWidth - 445 then move the preview to the left of the cursor
		var left_space = -60 // close the gap when we move the preview to the left of the cursor
		var flip_loc_y
		var scrolltop=0

		if(dragging == 1) return;

		//if(getprevobjnostyle('bodyContent').scrollTop)
		//	scrolltop=getprevobjnostyle('bodyContent').scrollTop
		//else
			scrolltop=truebody().scrollTop

		//if (document.forms.propsearch.toggle_lightbox.value == 1)
		var toggle=0;
		if (toggle == 1)
			flip_loc_y = 100
		else
			flip_loc_y = 300		//originally 200

		var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15

		//var docheight=document.all? Math.min(truebody().scrollHeight, truebody().clientHeight) : Math.min(document.body.offsetHeight, window.innerHeight)
		var docheight=document.all? truebody().clientHeight : window.innerHeight
	   var flip_x_amount = -15;


		if (typeof e != "undefined"){
			if (docwidth - e.pageX < flip_loc_x){
				//xcoord = e.pageX - flip_loc_x - offsetfrommouse[0] - 325 + left_space; // Move to the left side of the cursor
				xcoord = e.pageX - flip_loc_x - offsetfrommouse[0] - flip_x_amount + left_space; // Move to the left side of the cursor
			} else {
				xcoord += e.pageX;
			}
			if (docheight - e.pageY < (prev_h + flip_loc_y)){
				ycoord += e.pageY - Math.max(0,(flip_loc_y + prev_h + e.pageY - docheight - scrolltop));
			} else {
				ycoord += e.pageY;
			}

		} else if (typeof window.event != "undefined"){
			if (docwidth - event.clientX < flip_loc_x){ // changed from 300
				//xcoord = event.clientX + truebody().scrollLeft - flip_loc_x - 325 + left_space; // changed from 286 Move to the left side of the cursor
				xcoord = event.clientX + truebody().scrollLeft - flip_loc_x - flip_x_amount + left_space; // changed from 286 Move to the left side of the cursor
			} else {
				xcoord += truebody().scrollLeft+event.clientX
			}
			if (docheight - event.clientY < (prev_h + flip_loc_y)){
				ycoord += event.clientY + scrolltop - Math.max(0,(flip_loc_y + prev_h + event.clientY - docheight));
			} else {
				ycoord += scrolltop + event.clientY;
			}
		}

		var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
		var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)

    var scrOfX = 0, scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		scrOfY = window.pageYOffset; scrOfX = window.pageXOffset;
	} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft;
	} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft;
	}
			getprevobj("previewcontainer").top=scrOfY+20
			//getprevobj("previewcontainer").left=scrOfX+20
            getprevobj("previewcontainer").left=xcoord+"px"
			//getprevobj("previewcontainer").top=ycoord+"px"
			//getprevobj("previewcontainer").left = x - 150
			//getprevobj("previewcontainer").top = y - 70

	}


	function getprevobjnostyle(o){
		if (document.getElementById)
			return document.getElementById(o)
		else if (document.all)
			return document.all.o
	}

	function hideprev(){
			getprevobj("previewcontainer").visibility="hidden";
			getprevobj("previewcontainer").left="-1500px";
			document.onmousemove="";
	}

	function getprevobj(o){
		if (document.getElementById)
			return document.getElementById(o).style
		else if (document.all)
			return document.all.o.style
	}


	function truebody(){
	   return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
	}

	function _dls () {window.status = 'View Details'; return true}
	function _cls () {window.status = ''; return true}

function findObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function getImage(imageName)
{
		findObj('img').src = imageName;
}

