
function Run2ShopXmlHttpObject()
{
	var xmlHttp=null;
	try
	{	
	  xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{	
		try
		{
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function run2ShopAjaxCall(obj,scpt)
{
//	alert(obj);
	var reqUrl = obj.href+"/&mashup_list=1&sid="+Math.random();
	var request = reqUrl;
	
//	alert(request);
	
	var head = document.getElementsByTagName("head").item(0);
	
	if( document.getElementById('dynScript') ) {
		head.removeChild(document.getElementById('dynScript'));
	}
	
	var script = document.createElement("script");
  
  //head.removeChild(document.getElementById('dynScript'));
	
	script.setAttribute("id", "dynScript");
	script.setAttribute("src", request);
	head.appendChild(script);
  return false;

}

function run2ShopCallback(data) {
	
	// show modal	
	 $(data).modal({
        onOpen: contact_mashup.open,
        onShow: contact_mashup.show,
        onClose: contact_mashup.close
      });

}

var contact_mashup = {
  message: null,
  show: function (dialog) {
      $("a#modalClose").click(function(e){
          close(dialog);
      });
   
  },  
  close: function modalClose (dialog) {
  dialog.data.fadeOut('medium', function () {
    dialog.container.hide('fast', function () {
      dialog.overlay.slideUp('fast', function () {
        $.modal.close();
      });
    });
  });
},open: function (dialog)
  {
    dialog.overlay.fadeIn(100, function ()
 {
    dialog.container.fadeIn(100, function ()
    {
   dialog.data.fadeIn(100, function ()
   {
   });
    });
      });    

  }
}


function close(dialog)
{
    var sURL = unescape(window.location.pathname);
    window.location.href = sURL; 
    dialog.data.fadeOut('medium', function () {
    dialog.container.hide('fast', function () {
      dialog.overlay.slideUp('fast', function () {
        $.modal.close();
      });
    });
  });
  
}

function show_recom_allCallback(data) {
	
	// show modal	
	 $('.showroom-list-in-bottom-mashup').html(data).fadeIn(100);

}

function show_recom_detailCallback(data) {
	
	// show modal	
	 $('.showroom-list-in-bottom-mashup').html(data).fadeIn(100);

}

function show_update_thumb_Callback(data) {
	
	// show modal	
	$('.recommendation-single span.recom-thumb').html(data).fadeIn(50);

}

function run2ShopPostComment( formId, ifrmId ,back_path) { 

 document.getElementById(formId).target = ifrmId; 
 document.getElementById(formId).onload = setTimeout('comment_add_confirm_Callback("'+back_path+'")',30);
 
 return true;
}

function comment_add_confirm_Callback(back_path) {
		
 	var reqUrl = back_path+"/&mashup_list=1&sid="+Math.random();
	var request = reqUrl;
	
	var head = document.getElementsByTagName("head").item(0);
	
	if( document.getElementById('dynScript') ) {
		head.removeChild(document.getElementById('dynScript'));
	}
	
	var script = document.createElement("script");
	
	script.setAttribute("id", "dynScript");
	script.setAttribute("src", request);
	head.appendChild(script);
	
	return false;
}

function mashup_slideUp(obj)
{

var curSlide = obj.getAttribute("alt");
var slideToShow = 0;

if (curSlide == 2)
{
slideToShow =1;
}
else
{
slideToShow = parseInt(curSlide) + 1;
}

 $("#showroom_id-slide-" + curSlide).css('display', 'none');
 $("#showroom_id-slide-" + slideToShow).css('display', 'block');
//alert(curSlide);
	obj.setAttribute("alt", slideToShow);
	
	var slide_down_arrow = document.getElementById("slider_down-1");
	slide_down_arrow.setAttribute("alt", slideToShow);
}

function mashup_slideDown(obj)
{

var curSlide = obj.getAttribute("alt");
var slideToShow = 0;

	if (curSlide == 2)
	{
		slideToShow = 1;
	}
	else
	{
		slideToShow = parseInt(curSlide) + 1;
	}

 $("#showroom_id-slide-" + curSlide).css('display', 'none');
 $("#showroom_id-slide-" + slideToShow).css('display', 'block');
 obj.setAttribute("alt",slideToShow);
 var slide_up_arrow = document.getElementById("slider_up-1");
 slide_up_arrow.setAttribute("alt", slideToShow);
}


var today = new Date();
var expiry = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);

function r2s_addThumbUp(obj,recomm_id)
{
	var cookie_id='is_already_thumb'+recomm_id;

	acnhor={"href":obj};
	if (GetCookie(cookie_id) == null) {
		  SetCookie(cookie_id,1);
		  return run2ShopAjaxCall(acnhor,recomm_id);
	}
}

function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1) { endstr = document.cookie.length; }
  return unescape(document.cookie.substring(offset, endstr));
  }

function GetCookie (name) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg) {
      return getCookieVal (j);
      }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break; 
    }
    
  return null;
  }

function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
  }

function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
  }
