/*
   Script:                 						CJ_customscripts_v1.js

   Description:            						Includes all custom javascript functions for use in 
                           						aspdotnetsf system that are necessary to support antiquedb 
                           						system. 
   Modifications:

   BRD 2007-03-10: D00001-S00002 - 	  Added breakout, hoverover_edit, more_pack_info and the show_popup functions  
   									  to control the appearance and behavior of pack items.  
   BRD 2007-05-14: D00002-S00001 -    Added menu select form for selecting page parts on the new addinfo page. 
   BRD 2007-08-30: B00004-S00002 -    Placed javascript code in this routine to handle the fscommand 
   									  coming FROM the flash application CFLA_Prot.fla.
   BRD 2008-04-03: D00006-S00002 -	  Added functions jPolicyOpen and jFAQsOpen to process event clicks for opening FAQ and policy windows.
   
   BRD 2008-05-23: D00002-S00002 -    Added new tooltip code for displaying additional dimension and weight information 
									  on user hovering over picture.
   BRD 2008-08-19: D00006-S00002 -	  Added function jTopicOpen to process all terms and conditions queries.
   
   BRD 2009-01-26: D00002-S00005 -    Added addiitonal functions to display text in popups where user would require additional information.  
                                      E.g., for searching and using the % sign as a wildcard. 
   BRD 2000-10-28: D00014-S00004 -    Modifed hieght and width properties in more_info to 880 x 500 to accommodate return from email, obo and sell sep forms.
   BRD 2011-05-28: D00042-S00001 -    Modifed more_pack_info's width to accomodate more page information on landscape photos. 
   BRD 2011-05-21: D00042-S00002 -    Added confirm box to make user aware that they are purchasing only one item/page. 
*/


///* BRD 2009-01-26: D00002-S00005 - start*/

//Pop up information box II (Mike McGrath (mike_mcgrath@lineone.net,  http://website.lineone.net/~mike_mcgrath))
//Permission granted to Dynamicdrive.com to include script in archive
//For this and 100's more DHTML scripts, visit http://dynamicdrive.com

function popup(msg,bak){
    var content="<TABLE id=tableBak WIDTH=150 BORDER=1 BORDERCOLOR=black CELLPADDING=2 CELLSPACING=0 "+
    "BGCOLOR="+bak+"><TD ALIGN=center>"+msg+"</TD></TABLE>";
    yyy=Yoffset;
     if(ns4){skn.document.write(content);skn.document.close();skn.visibility="visible"}
     if(ns6){document.getElementById("dek").innerHTML=content;skn.display=''}
     if(ie4){document.all("dek").innerHTML=content;skn.display=''}
}

//function get_mouse(e){
//    var x=(ns4||ns6)?e.pageX:event.x+document.body.scrollLeft;
//    skn.left=x+Xoffset;
//    var y=(ns4||ns6)?e.pageY:event.y+document.body.scrollTop;
//    skn.top=y+yyy;
//}

function kill(){
    yyy=-1000;
    if(ns4){skn.visibility="hidden";}
    else if (ns6||ie4)
    skn.display="none"
}

///* BRD 2009-01-26: D00002-S00005 - end*/






/* BRD 2008-05-23: D00002-S00002 - start */

function xstooltip_findPosX(obj) 
{
  var curleft = 0;
  if (obj.offsetParent) 
  {
    while (obj.offsetParent) 
        {
            curleft += obj.offsetLeft
            obj = obj.offsetParent;
        }
    }
    else if (obj.x)
        curleft += obj.x;
    return curleft;
}

function xstooltip_findPosY(obj) 
{
	//debugger;
    var curtop = 0;
    if (obj.offsetParent) 
    {
        while (obj.offsetParent) 
        {
            curtop += obj.offsetTop
            obj = obj.offsetParent;
        }
    }
    else if (obj.y)
        curtop += obj.y;
    return curtop;
}


function xstooltip_show(tooltipId, parentId, posX, posY)
{
	//debugger;
    it = document.getElementById(tooltipId);
    
    if ((it.style.top == '' || it.style.top == 0) 
        && (it.style.left == '' || it.style.left == 0))
    {
        // need to fixate default size (MSIE problem)
        it.style.width = it.offsetWidth + 'px';
        it.style.height = it.offsetHeight + 'px';
        
        img = document.getElementById(parentId); 
    
        // if tooltip is too wide, shift left to be within parent 
        if (posX + it.offsetWidth > img.offsetWidth) posX = img.offsetWidth - it.offsetWidth;
        if (posX < 0 ) posX = 0; 
        
        x = xstooltip_findPosX(img) + posX;
        y = xstooltip_findPosY(img) + posY;
        
        it.style.top = y + 'px';
        it.style.left = x + 'px';
    }
    
    it.style.visibility = 'visible'; 
}

function xstooltip_hide(id)
{
	//debugger;
    it = document.getElementById(id); 
    it.style.visibility = 'hidden'; 
}



/* BRD 2008-05-23: D00002-S00002 - end */



/* BRD 2011-05-30: D00043-S00001 - start 
function MouseOverImg() {
  debugger;
  document.image_delete.src="skins/skin_1/images/edit5.png";
  ddrivetip('<div class=\"exampleText\">Click to buy this item.</div>');
}
function MouseOutImg() {
    document.image1.src = "skins/skin_1/images/edit4.png";
    hideddrivetip();
}


 BRD 2011-05-30: D00043-S00001 - end */

/* This function is called from a pack product whenever someone hits the individual item, goto button.
	 It redirects the user to the individual item. */

function breakout(txt) {
	self.location=txt
}

/* BRD 2007-03-10: D00001-S00002 - start */

/* This function is called whenever the user 'hovers' over an item 
*/
function hoverover_edit(altTxt){
	//debugger;
	document.getElementById('image_delete').title=altTxt;

	
}
//BRD 2011-06-01 D00042-S00002 - start

function add_to_cart(params) {
   
    var CF4_NoteMess = 'NOTE: Please confirm you are purchasing only ** ONE ** page or item.  If you have any questions, please contact customer service.';
    if (!confirm(CF4_NoteMess)) {
        //debugger;
        return (false);
    } else {
                //debugger;
                location.replace("addtocart.aspx?" + params);
            }
}

//BRD 2011-06-01 D00042-S00001 - end

/* This function is invoked when the user generates a mouse 'onclick' event.  It opens an html file that 
   is passed by way of the URLtxt parameter. 
*/
   
   
function more_pack_info(URLtxt){
	
	//window.open(URLtxt,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=600, height=360")
    //BRD 2000-10-28: D00014-S00004 start
    //BRD 2011-05-28: D00042-S00001 start
    //window.open(URLtxt, "_blank", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=880, height=640")
    window.open(URLtxt, "_blank", "screenX=50,screenY=50,top=50,left=50,toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=940, height=640")
    //BRD 2011-05-28: D00042-S00001 end
	//BRD 2000-10-28: D00014-S00004 end
}

function more_pack_info2(URLtxt){
	
	//window.open(URLtxt,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=600, height=360")
	//BRD 2000-10-28: D00014-S00004 start
	window.open(URLtxt,"_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=no, width=600, height=360")
	//BRD 2000-10-28: D00014-S00004 end
}

/* This is another implementation of the mouseclick event.  It uses a popup window to display text instead
   of a seperate browser window. 
*/

/* "This is a pop-up! Click outside the pop-up to close." */
function show_popup(innerHTMLtxt)
{
	var p=window.createPopup()
	var pbody=p.document.body
	pbody.style.backgroundColor="Beige"
	pbody.style.border="solid white 1px"
	pbody.innerHTML=innerHTMLtxt
	p.show(150,150,200,50,document.body)
}

/* BRD 2007-03-10: D00001-S00002 - end */

/* BRD 2007-05-14: D00002-S00001 - start */

function dropdown(mySel)
{
	var myWin, myVal;
	myVal = mySel.options[mySel.selectedIndex].value;
	if(myVal)
	{
		if(mySel.form.target)myWin = parent[mySel.form.target];
			else myWin = window;
		if (!myWin) return true;
			myWin.location = myVal;
	}
	return false;
}

/* BRD 2007-05-14: D00002-S00001 - end */


/* BRD 2007-08-30: B00004-S00002 - start */


// Handle all the FSCommand messages in a Flash movie.
function CFLA_Prot_DoFSCommand(command, args) {
	var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
	var CFLA_ProtObj = isInternetExplorer ? document.all.CFLA_Prot : document.CFLA_Prot;
	
	if (command == "messagebox") {
		 alert(args);
 	}
 	else
 	{
 		//NewWindow=window.open('test1.html','newWin','width=400,height=300,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No');
 		//alert(args);
 		//NewWindow=window.open(args,'newWin','width=375,height=500,left=0,top=0,toolbar=no,location=no,scrollbars=Yes,status=no,resizable=no,fullscreen=no');
 		//NewWindow=window.open(args);
 		//window.open(args);
 		NewWindow=window.open(args);
 	}

}
// Hook for Internet Explorer.
//if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) 
//{
//	document.write('<script language=\"VBScript\"\>\n');
//	document.write('On Error Resume Next\n');
//	document.write('Sub CFLA_Prot_FSCommand(ByVal command, ByVal args)\n');
//	document.write('	Call CFLA_Prot_DoFSCommand(command, args)\n');
//	document.write('End Sub\n');
//	document.write('</script\>\n');
//}
/* BRD 2007-08-30: B00004-S00002 - end */


/* BRD 2008-04-03: D00006-S00002 - start */
//function jPolicyOpen(PolicyCatKey,topic,w,h,scrollbars)
//{
//			if(PolicyCatKey == "20" || PolicyCatKey == "1")
//			{
//				window.open('CASP_Policies.aspx?PolicyCatKey=' + PolicyCatKey + '&topic=' + topic,'PopupReturns','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=yes,copyhistory=no,width=' + w + ',height=' + h + ',left=0,top=0');
//			}
//			else
//			{ .
//				window.open('CASP_Policies.aspx?PolicyCatKey=' + PolicyCatKey + '&topic=' + topic,'PopupReturns','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=yes,copyhistory=no,width=' + w + ',height=' + h + ',left=0,top=0');			
//			}
//			
//}

function jFAQsOpen(policykey,policygroup,topic,w,h,scrollbars)
{			
	window.open('CASP_Faqs.aspx?policykey=' + policykey + '&policygroup=' + policygroup + '&topic=' + topic,'PopupReturns','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=yes,copyhistory=no,width=' + w + ',height=' + h + ',left=0,top=0');						
	//window.open('CASP_Faqs.aspx?policykey=' + policykey + '&policygroup=' + policygroup + '&topic=' + topic + 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=yes,copyhistory=no,width=' + w + ',height=' + h + ',left=0,top=0');						
}


/* BRD 2008-04-03: D00006-S00002 - end */

/* BRD 2008-08-19: D00006-S00002 - start */
//function jTopicOpen(TopicKey,topic,w,h,scrollbars)
//{
//			//debugger;
//			window.open('CASP_Topics.aspx?TopicKey=' + TopicKey + '&topic=' + topic,'PopupReturns','toolbar=yes,location=yes,directories=no,status=no,menubar=yes,scrollbars=' + scrollbars + ',resizable=yes,copyhistory=no,width=' + w + ',height=' + h + ',left=0,top=0');
//}

/* BRD 2008-04-03: D00006-S00002 - end */

