function SideMenu()
{	
	var body = document.getElementById("body");
	
	var middle = document.getElementById("middle");
	
	var middle_container = document.getElementById("middle_container");
	
	var linen = document.getElementById("linen");
	
	var homepagediv = document.getElementById("homepage");
	
	/*if(body.offsetHeight < 450)
	{
		body.style.height='450px';
	}
	
	middle.style.height = body.offsetHeight + "px";
	middle_container.style.height = body.offsetHeight + "px";
	*/
	var sidemenu = document.getElementById("side_menu");
	var franchisemenu = document.getElementById("franchise_menu");
	var howmenu = document.getElementById("how_menu");
	
	var check = sidemenu.innerHTML.search(/</);
	if(check==-1)
	{
		sidemenu.style.display = 'none';
	}
	else
	{
		if(sidemenu.offsetHeight<body.offsetHeight - 61)
		{
			sidemenu.style.height = body.offsetHeight - 70 + "px";
		}
		body.style.width='663px';
	}
	var check2 = franchisemenu.innerHTML.search(/</);
	if(check2==-1)
	{
		franchisemenu.style.display = 'none';
	}
	else
	{
		if(franchisemenu.offsetHeight<body.offsetHeight - 61)
		{
			franchisemenu.style.height = body.offsetHeight - 70 + "px";
		}
		body.style.width='663px';
	}
	var check3 = howmenu.innerHTML.search(/</);
	if(check3==-1)
	{
		howmenu.style.display = 'none';
	}
	else
	{
		if(howmenu.offsetHeight<body.offsetHeight - 61)
		{
			howmenu.style.height = body.offsetHeight - 70 + "px";
		}
	}
	
	var logo_image = document.getElementById('logo_image');
	
	
	//positioning buttons facebook,catalog,newsletter
	var logo_image = document.getElementById('logo_image');
	if(logo_image)
	{
		pos = findPosition(logo_image);
		
		var tellFriend = document.getElementById('tell_a_friend');
		if (tellFriend!=null)
		  tellFriend.style.display="";
	}
	//...
	
	
	
	var fc = document.getElementById("flashwrapper");
	if (fc != null)
	 fc.style.display = '';
	
	//suckerfish
	/*sfHover = function() {
   var sfEls = document.getElementById("mainlevelmainnav").getElementsByTagName("LI");
   for (var i=0; i<sfEls.length; i++) {
      sfEls[i].onmouseover=function() {
         this.className+=" sfhover";
      }
      sfEls[i].onmouseout=function() {
         this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
      }
   }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);*/
}

function showMiddle(comp)
{
  /*if (comp == "com_rekry")
  {
    
    var test = document.getElementById("middle");
    if (test != null)
    {
      alert(1);
      test.style.display="";
    }
  }*/
}

function redirect(cat_id)
{
	window.location = "index.php?option=com_virtuemart&page=shop.browse&vmsearch=0&lang=en&category_id=" + cat_id;
}

function redirect_clearance(cat_id)
{
	window.location = "index.php?option=com_virtuemart&page=shop.browse&vmoption=3&lang=en&category_id=" + cat_id;
}
function redirect_clearance_(cat_id,page)
{
	window.location = "index.php?option=com_virtuemart&page=shop.browse&vmoption=3&lang=en&category_id=" + cat_id + "&pnpage=" + page;
}

function redirect(cat_id,page)
{
	window.location = "index.php?option=com_virtuemart&lang=en&page=shop.browse&category_id=" + cat_id + "&pnpage=" + page;
}
function redirect_linencat(cat_id)
{
	window.location = "index.php?option=com_virtuemart&lang=en&page=shop.browse&vmoption=4&vmsearch=0&category_id=" + cat_id;
}
function redirect_linencat(cat_id,page)
{
	window.location = "index.php?option=com_virtuemart&lang=en&page=shop.browse&vmoption=4&category_id=" + cat_id + "&pnpage=" + page;
}
function redirect_flypage(pid)
{
	window.location = "index.php?option=com_virtuemart&lang=en&flypage=" + pid;
}

function redirect_contactus()
{
	window.location = "index.php?option=com_contactus&lang=en";
}

function redirect_products()
{
	window.location = "index.php?option=com_virtuemart&vmoption=1&Itemid=63&lang=en";
}

function redirect_linen(line_id,package_id,largeimage,path)
{
  image_td_id = document.getElementById('package_large_image');
  if (largeimage != '*')
  {
  
  image_td_id.innerHTML = "<img title='' alt='' src='"+path+"comfort/phpThumb/phpThumb.php?src="+path+"administrator/components/com_packages/images/"+largeimage+"&w=593&h=256&q=100' />";
  }
  else{
    image_td_id.innerHTML = "Large Image Not Available.";
  }
//  image_td_id.innerHTML = "";
	//window.location = "index.php?option=com_virtuemart&lang=en&vmoption=2&line_id=" + line_id + "&package_id=" + package_id;
}

function redirect_linen2(line_id,package_id,largeimage,path,line_name,line_desc,langu)
{
  /*image_td_id = document.getElementById('package_large_image');
  line_info = document.getElementById('line_name_desc');
  if (largeimage != '*')
  {
  
  image_td_id.innerHTML = "<img title='' alt='' src='"+path+"comfort/phpThumb/phpThumb.php?src="+path+"administrator/components/com_packages/images/"+largeimage+"&w=593&h=256&q=100' />";
  }
  else{
    image_td_id.innerHTML = "Large Image Not Available.";
  }
//  image_td_id.innerHTML = "";
	//window.location = "index.php?option=com_virtuemart&lang=en&vmoption=2&line_id=" + line_id + "&package_id=" + package_id;
	line_info.innerHTML = "<font id='line_name' style='font-size:15pt;font-family:\"Trebuchet MS\";font-weight:bold;color:black;'>"+line_name+"</font><br><font style='font-size:10pt;font-family:\"Trebuchet MS\";color:black;'>"+testEncodedHtml(line_desc)+" </font>";*/
  loadRightMenu(package_id,path,langu,line_id);
  /*loadLineColors(line_id,path);*/
  
}

function encodeMyHtml(myText) {
	encodedHtml = escape(document.getElementById(myText).value);
	encodedHtml = encodedHtml.replace(/\//g,"%2F");
	encodedHtml = encodedHtml.replace(/\?/g,"%3F");
	encodedHtml = encodedHtml.replace(/=/g,"%3D");
	encodedHtml = encodedHtml.replace(/&/g,"%26");
	encodedHtml = encodedHtml.replace(/@/g,"%40");
	return encodedHtml;
}
function testEncodedHtml(myText) {
	testEL = unescape(myText);
	return testEL;
}

function loadRightMenu(package_id,path,langu,line_id){
		jQuery.ajax({
			type: "POST",
			url: "/linen_ajax.php",
			data: 	"path=" + path +"&package_id=" + package_id+"&lang=" + langu + "&line_id=" + line_id,
			success: function(html){
				$("#linen_div").html(html);
			},
		});
}
function loadLineColors(line_id,path){
	jQuery.ajax({
		type: "POST",
		url: path+"linen_line_colors_ajax.php?lang=en",
		data: 	"path=" + path +"&line_id=" + line_id,
		success: function(html){
			$("#line_colors").html(html);
		}
	});
	
	}
		
function redirect_linen1(line_id,package_id)
{
	window.location = "index.php?option=com_virtuemart&lang=en&vmoption=2&line_id=" + line_id + "&package_id=" + package_id;
}

function redirect_location(str)
{
	window.location = str;
}

//find position code
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;
  }

  obj.style.position = "static";

  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 findPos(obj) {
  var left = findPosX(obj);
  var top = findPosY(obj);

  return [left , top];
}

function findPosition( oElement ) {
  if( typeof( oElement.offsetParent ) != 'undefined' ) {
    for( var posX = 0, posY = 0; oElement; oElement = oElement.offsetParent ) {
      posX += oElement.offsetLeft;
      posY += oElement.offsetTop;
    }
    return [ posX, posY ];
  } else {
    return [ oElement.x, oElement.y ];
  }
}
//...

//contact us
/*function checkselect(selectid)
{
//	alert('test');
   var myselect=document.getElementById(selectid);
   if(myselect.options[myselect.selectedIndex].value == 'other')
	 {
	 		var e = document.getElementById('subject');
	 		e.type = 'text';
	 }
	 else
	 {
	 		var e = document.getElementById('subject');
	 		e.type = 'hidden';
	 }
}*/

function expand_select(id)
{
  id.style.width='110px';
}

function collapse_select(id)
{
  id.style.width='70px';
}
