﻿function mcdivs()
{
$j(document).ready(function(){
  $j("div.Button").click(function(){
  a = $j(this);
  var basketoffset = $j('#BasketForQuery').offset();
  var gWidth = $j('#BasketDiv').innerWidth() + 20;
  $j("#AddToCartDiv").css('width',$j('#BasketDiv').innerWidth() + 28);
  $j("#AddToCartDiv").css('height', Math.ceil((600 * gWidth / 419) + 90));
  //$j("#AddToCartDiv").css('height', Math.ceil((204 * gWidth / 143) + 38));
  
  $j("#AddToCartDiv").css('top', basketoffset.top + $j('#BasketDiv').innerHeight());
  $j("#AddToCartDiv").css('left', basketoffset.left + $j('#BasketForQuery').innerWidth() -$j('#AddToCartDiv').innerWidth());
  $j.get("InsertProductToCart.aspx", "ProductID=" + $j(this).attr("CommandArgument") + "&Language=" + mcQueryStr('Language') + "&Width=" + gWidth, function(data){
    $j("#AddToCartDiv").html(data);
    $j("#borderdiv").css('width', gWidth);
    $j("#AddToCartDiv").slideDown(1000, function(){
        $j("#CartBar").animate({width: gWidth + "px"}, 900);
        setTimeout(function(){
        $j("#AddToCartDiv").slideUp(750, function(){
        $j.get("ReturnCartInfo.aspx", "Language=" + mcQueryStr('Language'), function(seconddata){
            $j("#BasketDiv").html(seconddata);
        });});}, 1500);});
    
    });
  });
  
  $j(".policy").click(
  function(){
    var pWidth = $j(this).innerWidth();
    var pHeight = $j(this).innerHeight();
    //alert(pWidth); <div id='PricePolicy<%# Eval("ProductID") %>' class="PricePolicy"></div>
    var pOffset = $j(this).position();
    var idarg = $j(this).attr("idarg");
    var selector = "#PricePolicy" + idarg;
    //var pSelector = "#Price" + idarg;
    $j.get("GetPolicy.aspx", "ProductID=" + idarg + "&Language=" + mcQueryStr('Language'), function(data){    
    $j(selector).html(data);
    $j(selector + " > table").css('width', pWidth - 4);
    $j(selector).css('width', pWidth - 4);
    $j(selector).css('left', pOffset.left);
    $j(selector).slideDown(1000, function(){
    setTimeout(function(){$j(selector).slideUp(1000);}, 3000);
    });
    });
    
  });
  
});
}

function mcQueryStr(mystr) {
sub = window.location.search.substring(1);
pair = sub.split("&");
for (i=0;i<pair.length;i++) 
{
    ft = pair[i].split("=");
    if (ft[0] == mystr) 
    {
        return ft[1];
    }
}
}

var strEmailString = "_r=1";

function GetContentWnd(){ return parent; }

function OnEmail(){

var oWnd = GetContentWnd();

var oDoc = oWnd.document;

var oDescription = oDoc.getElementById("Description");

var strDescription = ( (oDescription == null) || (oDescription.content == "") ) ? oDoc.title : oDescription.content; 

if( oDoc.title == "" )

oWnd.location.href = "mailto:?body="+BuildEmailDescription(strDescription, oWnd.location.href);

else

oWnd.location.href = "mailto:?subject="+"Something interesting you might want to see!" +"&body="+BuildEmailDescription(strDescription, oWnd.location.href);

return true;

}

function BuildEmailDescription(strDescription,hRef){

//return escape("Here's a great article you might be interested in:" + String.fromCharCode(13)+ String.fromCharCode(13) + strDescription + String.fromCharCode(13) + "URL: " + hRef);

return escape("URL: " + hRef);

}

function AddParamToURL(strLoc,strParam){

var i = strLoc.lastIndexOf("?");

if(strLoc.indexOf(strParam, i) >= 0)

return strLoc;


strLoc += ((i >= 0) && (i > strLoc.lastIndexOf("/"))) ? "&" : "?";

return strLoc + strParam;

}
