
function  MM_PreLoadImagesArray(){
	
	MM_preloadImages('../images/link_home_over.png','../images/link_about_over.png','../images/link_products_over.png','../images/link_media_over.png','../images/link_store_over.png', '../images/link_accessories_hover.png', '../images/link_homewares_hover.png', '../images/link_fashion_hover.png')
}
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_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_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 closewindow_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.sublimes&&i<d.sublimes.length;i++) x=closewindow_findObj(n,d.sublimes[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function closewindow_Cascadingsublimes() {

	
  var i,p,v,obj,args=closewindow_Cascadingsublimes.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=closewindow_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
	
	
}


function showMenu(imgId, div, addValueX, addValueY)
{
		
	
	var strVersion;
	strVersion = navigator.appVersion;
	strVersion = strVersion.toLowerCase();
	
	
	var cellposx = findPosX(document.getElementById(imgId));
	var cellposy = findPosY(document.getElementById(imgId));

	cellposy = cellposy + addValueY;
	

	var d = document.getElementById(div);
	var m = document.getElementById('menuspace');
	
	//alert(d.offsetHeight);
	
		m.style.height  = d.offsetHeight - 8 + "px";
	
	d.style.left	= cellposx + "px";
	d.style.top		= cellposy + "px";
	closewindow_Cascadingsublimes('qhi0','','show','qhi1','','hide','qhi2','','hide');
	 
	 

}

function hideMenu(tagName, a, act) {
	
	var m = document.getElementById('menuspace');
	m.style.height  = 20+ "px";
	
	
	closewindow_Cascadingsublimes(tagName, a, act);
	
	
}
/**
* Pops up a new window in the middle of the screen
*/

function popupProduct(objImg, folder, myname, w, h, scroll) {
	
	var mypage ;
	var lastDot;
	var srcLength;
	var tempSrc;
	var lastSlash;
	
	mypage		= objImg.src;
		
	lastDot 	= mypage.lastIndexOf('.');
	
	srcLength	= mypage.length;
	
	tempSrc		= mypage.substring(0, lastDot);
	
	lastSlash 	= tempSrc.lastIndexOf('/');
	
	srcLength	= tempSrc.length;
	
	tempSrc		= tempSrc.substring(srcLength, lastSlash+1);
	
	srcLength	= tempSrc.length;
	
	tempSrc		= tempSrc.substring(0, srcLength-3);
	
	tempSrc		= folder+"/popups/"+tempSrc+"popup.jpg";
	
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
	win = window.open('popup.php?img='+tempSrc, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

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 to show main image on click of thumbnaul on product page
  function showMainImage(objImg, folder) {
	  
	  var tempSrc;
	  var imgNo;
	  
	  tempSrc = getfileName(objImg.src);
	
	  var desti;
	  document.images['mainbox'].src =  "images/"+folder+"/"+tempSrc+"_big.png";
	  // alert("images/products/"+objImg.name+"_big.jpg");
	  
	  // alert (tempSrc.substring(0,1));
	  
	  if (tempSrc.substring(0,1) == 'a')
	  {
		  imgNo = parseInt(tempSrc.substring(12,14), 10) - 1;
	  }
	  else if (tempSrc.substring(0,5) == 'homew')
	  {
		  imgNo = parseInt(tempSrc.substring(10,12), 10) - 1;
	  }
	  else if (tempSrc.substring(0,1) == 'f')
	  {
		  imgNo = parseInt(tempSrc.substring(7,9), 10) - 1;
	  }
	  else if (tempSrc.substring(0,6) == 'burkes')
	  {
		  imgNo = parseInt(tempSrc.substring(17,19), 10) - 1; 
	  }
	  else if (tempSrc.substring(0,6) == 'herald')
	  {
		  imgNo = parseInt(tempSrc.substring(11,12), 10) - 1;
	  }
	  else if (tempSrc.substring(0,6) == 'home_b')
	  {
		  imgNo = parseInt(tempSrc.substring(15,17), 10) - 1;
	  }
	  else
	  {
		  return;
	  }
	  
	  // imgNo = parseInt(tempSrc.substring(10,12), 10) - 1;
	  
	  // alert(tempSrc);
	  
	  // alert(tempSrc.substring(12,14));
	  
	  // alert(parseInt(tempSrc.substring(10,12), 10));
	  
	  t=document.getElementById( 'price' ).rows[0];
	  t.cells[0].innerHTML = "<div class=productlink>" + descriptions[imgNo] + "</div>";
	  t.cells[1].innerHTML = "<div class=productlink>" + prices[imgNo] + "</div>";
	  
  }
  
  
  //CODE FOR COLLECTION AND MEDIA PAGE
//************************************************
	var nextid,previd;
	function navigateProducts(actId)
	{
		
		
		var str1,str2;
		var img1=document.getElementById("imgfirst");
		var img2=document.getElementById("imgsecond");
		var img3=document.getElementById("imgthird");
		var img4=document.getElementById("imgfourth");
		var txt1=document.getElementById("txtHid1");
		var txt2=document.getElementById("txtHid2");
		var txt3=document.getElementById("txtHid3");
		var txt4=document.getElementById("txtHid4");
		
		if (actId=='next')
		{
			if (nextid != -1)
			{
				
				if (arrprod.length>=(nextid-3))
				{
					fillImageDetails(img1,arrprod[(nextid-3)]);
					txt1.value=(nextid-3)+1;
				}	
				if (arrprod.length>=(nextid-2))
				{
					fillImageDetails(img2,arrprod[(nextid-2)]);
					txt1.value=(nextid-2)+1;
				}		
				if (arrprod.length>=(nextid-1))
				{
					fillImageDetails(img3,arrprod[(nextid-1)]);
					txt2.value=(nextid-1)+1;
				}
				if (arrprod.length>=nextid)
				{
					fillImageDetails(img4,arrprod[nextid]);
					txt3.value=nextid+1;
				}
				previd = nextid-4;			
				if ((nextid+1)<=(arrprod.length-1))
				{
					nextid++;
				}
				else
				{
					nextid=-1;
				}
				//setFrameSourceNull();
			}
		}
		else
		{
			if (previd != -1)
			{
				nextid=previd+4;
				if (arrprod.length>=(nextid-2))
				{
					fillImageDetails(img1,arrprod[previd]);
					txt1.value=previd+1;
				}
				if (arrprod.length>=(previd+1))
				{
					fillImageDetails(img2,arrprod[(previd+1)]);
					txt2.value=(previd+1)+1;
				}
				if (arrprod.length>=previd+2)
				{
					fillImageDetails(img3,arrprod[(previd+2)]);
					txt3.value=(previd+2)+1;
				}
				if (arrprod.length>=previd+3)
				{
					fillImageDetails(img4,arrprod[(previd+3)]);
					txt3.value=(previd+3)+1;
				}
				if ((previd-1)>=0)
				{
					previd--;
				}
				else
				{
					previd=-1;
				}
				//setFrameSourceNull();
			}
		}
	}
	
	function fillImageDetails(imgId,strFill)
	{
		var str1,str2,str3;
		str1=strFill.split("*");
		imgId.alt=str1[1];
		imgId.title=str1[1];
		imgId.src=str1[0];
	}

	function initializeProducts(folder)
	{
		var str1,str2;
		var img1=document.getElementById("imgfirst");
		var img2=document.getElementById("imgsecond");
		var img3=document.getElementById("imgthird");
		var img4=document.getElementById("imgfourth");
		var txt1=document.getElementById("txtHid1");
		var txt2=document.getElementById("txtHid2");
		var txt3=document.getElementById("txtHid3");
		var txt4=document.getElementById("txtHid4");
		
		var imgMain =  document.getElementById("mainbox");
		
		
		previd=-1;
		if (arrprod.length>=0)
		{
			
			// Show Image in Frame
			tempSrc = getfileName(arrprod[0]);
			tempSrc	= "images/"+folder+"/"+tempSrc+"_big.png*Harem Melbourne";
			
			fillImageDetails(imgMain,tempSrc);
			
			//end Image in frame
			
			fillImageDetails(img1,arrprod[0]);
			txt1.value=1;
		}
		
		if (arrprod.length>=1)
		{
			fillImageDetails(img2,arrprod[1]);
			txt2.value=2;
		}
		if (arrprod.length>=2)
		{
			fillImageDetails(img3,arrprod[2]);
			txt3.value=3;
		}
		if (arrprod.length>=3)
		{
			fillImageDetails(img4,arrprod[3]);
			txt4.value=4;
		}
		if (arrprod.length>=4)
		{
			nextid=4;
		}	
		else
		{
			nextid=-1;
		}	
		//setFrameSourceNull();
	}
	
	function selectFirstProduct(pgnamedetails,pgnameimage)
	{
		if (arrprod.length>=0)
		{
			setDetailIFrameSource(pgnamedetails,pgnameimage,'img0','txtHid0');
		}
	}


function getfileName(url) {
	
	var mypage ;
	var lastDot;
	var srcLength;
	var tempSrc;
	var lastSlash;
	
	mypage		= url;
		
	lastDot 	= mypage.lastIndexOf('.');
	
	srcLength	= mypage.length;
	
	tempSrc		= mypage.substring(0, lastDot);
	
	lastSlash 	= tempSrc.lastIndexOf('/');
	
	srcLength	= tempSrc.length;
	
	tempSrc		= tempSrc.substring(srcLength, lastSlash+1);
	
	return tempSrc;
	
}
