//<!--


/*  ' =================================================================
	' Update Window Title while loading document.
	' add to onload of body tag
	' trgt = 'parent.parent' path to top level
    ' =================================================================*/
function title_upd(str, trgt){
	try{
		
		var t = str; 
		if(trgt.length > -1){
			eval(trgt).document.title = t;	
		}else{
			document.title = t;
		}	
		
	}catch(e){}
	
}


/////////////////////////////////////////////////////////////////////////////////////////
var MyRange;
var range;
function promptMe(str1, str2, eType, formTitle){
/// prompt using a form specified and a grey transparent background
/////////////////////////////////////////////////////////////////////////////////////////

/*

// --- include this into your styles

	.detailsPanel {
		z-index: 100;
		top:150px;
		left:150px;
		height: 300px;
		width: 400px;
		position: absolute;
		margin-right: 80px;
		margin-left: 80px;
		background-image: url(/admin/editor/images/backgroundpanel.png);
		background-repeat: no-repeat;
	}
	
	.bodyCover{
		z-index: 90;
		position: absolute;
		top:0px;
		left:0px;
		height: 100%;
		width: 100%;
		margin-right: 0px;
		margin-left: 0px;
		background-color:#000000;
		background-repeat: no-repeat;
	    filter:alpha(opacity=20);
	    opacity: 0.2;
	    -moz-opacity:0.2;	
	
	}	

 // --- Include this into your document
  <div class="detailsPanel" id="Basket_1_Div" style="display:none;">
    <div class="controlPanel">
		<span style="padding:2px;background-color:#EFEFEF;" >
			<a href="javascript: void displayThis('Basket_1_Div','bodyCoverDiv');" target="_top">[close]</a>
  			<span id="frmTitle">Form:</span>
		</span>
		<IFRAME src="" 
		name="PwdIFr" id="PwdIFr"
		frameborder="0" scrolling="auto" style="width:100%; height:100%" > </iframe>

	</div><!-- controlPanel -->
  </div><!-- detailsPanel -->
  <div class="bodyCover" id="bodyCoverDiv"  style="display:none;">

  </div>

  
  
*/


    /// get selection in the document
//	MyRange= document.PreviewIFr.idEdit.document.selection
//    range  = MyRange.createRange();
    //alert( range.htmlText );
//    range.pasteHTML(str)

	rStr = str1 + str2;
	    
	document.getElementById("frmTitle").innerHTML = formTitle;

	//' --- display the transparent background and the password form
	displayThis("Basket_1_Div","bodyCoverDiv");
	
	// ' --- Show encrypt-decrypt form
	if(eType=="Encrypt" || eType=="Decrypt"){
		rStr = sPwdForm(eType);
	}

	if(eType=="Replace"){
		rStr = sReplaceForm(eType);
	}

	if(eType=="createLinkAdvanced"){
		rStr = sCreateLinkAdvancedForm(eType);
	}
	if(eType=="EADD_BOOK_SLOT"){
		// Ajax writes directly into specified DIV
		//alert("'promptMeDiv', 'EADD_BOOK_SLOT'" + ", str1+2: " + str1 + ";" + str2);
		rStr = 	getSelect("promptMeDiv", "EADD_BOOK_SLOT", "", str1 + ";" + str2);
	}
	
	if(document.PwdIFr){
		var pd = document.PwdIFr.document;
		pd.open(); 
		pd.write(rStr); 
		pd.close();
	}
	
	
	
	return false;
	
}



// /////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ***Begin library code better placed in an external API***
// Set global variables for browser detection and reference building
var isNav, isIE, intervalID
var coll = ""
var styleObj = ""
if (parseInt(navigator.appVersion) >= 4) {
	if (navigator.appName == "Netscape") {
		isNav = true
	} else {
		isIE = true
		coll = "all."
		styleObj = ".style"
	}
}



//////////////////////////////////////////////////
/// Expanding and collapsing

//onKeyDown=" & chr(34) & "expandThis('" & arySfNam(i) & "',10); " & chr(34) & " onBlur=" & chr(34) & "collapseThis('" & arySfNam(i) & "',1);" & chr(34) & "

//////////////////////////////////////////////////
/// expandThis(fld, rows) Expand textarea field
//////////////////////////////////////////////////
function expandThis(fld_, rows_){
	var fld = eval("document.form1."+fld_)
	if(rows_){
		if (fld.rows !=rows_){
			fld.rows = rows_;
			//alert(fld.rows)
		}
	}
	return true;
}

//////////////////////////////////////////////////
var preHeight;
function setStyle(obj,nameValueList){
//////////////////////////////////////////////////
	//alert("'" + arguments[0] + "' '" + arguments[1] + "'")
	var o = document.getElementById(obj);
	//alert("obj: " + obj + "\no: " + o );
	var nvL = nameValueList.split(";")
	var m = "";
	preHeight = o.style.height;
	for(i = 0; i < nvL.length;i++){
		if (nvL[i].length > 0){
			m += "(" + i + "): " + nvL[i] + "\n";
			var s = nvL[i].split(":");
			m += "(" + i + "): " + s[0] + ": " + s[1] + ";\n";
			if(s[0]=="overflow"){
				if(o.style.height.length <= 0){o.style.height = "150px";}
				if(o.style.overflow == s[1]){
					o.style.height = preHeight;
					o.style.overflow = "auto";
					
				}else{
				
					o.style.overflow = s[1];
				}
			}else{
				o.style[s[0]] = s[1];
			}
			m += " set: o.style[" + s[0] + "].height: " + o.style[s[0]].height + ""
			m += " set: o.style[" + s[0] + "]: " + o.style[s[0]] + ""
		}
	}	
	//alert(m);
}
//////////////////////////////////////////////////
/// collapseThis(fld_, rows_) collapse textarea field
//////////////////////////////////////////////////
function collapseThis(fld_, rows_){
	var fld = eval("document.form1."+fld_)
	var rw = 0;
	var cl = fld.cols;
	
    var re = /\n/ig;    			//Create regular expression pattern.
	var r = fld.value.match(re);    //Attempt match on search string.
	if(r!=null){
	  rw = r.length + 1
	}else{
	  rw = 1
	  if (rw < rows_){rw=rows_}
	  if ((fld.value.length/rw)>cl){
	  	rw=Math.ceil(fld.value.length/cl);
	  }
	}
	fld.rows = rw
	return true;
}

////////////////////////////////////////////////////////
function swapHelp(what_,force_){
//// If help is hidden by default
//// this allows us to turn it on or of 
//// when clicking on a field name.
////////////////////////////////////////////////////////

	var dv = document.getElementById(what_); //eval("document.all."+what_)
	var dt = document.getElementById(what_+"t"); //eval("document.all."+what_+"t")
	if(force_ == "on"){dv.style.visibility = "hidden";} 		//' --- force obj to be shown
	if(force_ == "off"){dv.style.visibility = "visible";} 		//' --- force obj to be hidden
	if (dv.style.visibility == "visible"){
		dv.style.visibility = "hidden";
		dv.style.display = "none";
		dt.innerHTML = "	<a href=\"javascript: void swapHelp(\'"+what_+"\',\'\');\" class=\"HelpSwp\" title=\"Click here to show help.\">?</a>\&nbsp\;on&nbsp;"
	}else{
		dv.style.visibility = "visible";
		dv.style.display = "inline";
		dt.innerHTML = "	<a href=\"javascript: void swapHelp(\'"+what_+"\',\'\');\" class=\"HelpSwp\" title=\"Click here to hide help.\">?</a>\&nbsp\;off&nbsp;"
	}
}


////////////////////////////////////////////////////////
//// If dropdownbox has an other value
//// doOther(frm, fldnme, ofldnme)
////////////////////////////////////////////////////////
  function doOther(frm_, fldnme_, ofldnme_, OtherVal_){
	var frm = arguments[0];    		//' --- form
	var fldnme  = arguments[1];		//' --- field name
	var ofldnme = arguments[2];		//' --- other field field name
	var OtherVal;
	//' --- get more arguments of the function
	if (arguments.length > 3){
		OtherVal = arguments[3]; //' --- value of the <option value="Other"... can be any value
	}else{
		OtherVal = "Other"
	}
	//alert(OtherVal);
  	//alert(frm + ", " + fldnme + ", " + ofldnme + "\n")
	var otherFound = false;
    var f = eval("document."+frm)
    var fld = eval("document."+frm+"."+fldnme)
	var ofld = eval("document."+frm+"."+ofldnme)
	var oDiv = eval("document.all."+fldnme+"DIV")
	var m
	//' --- is 'Other' selected?
	for (var i = 0; i< fld.options.length; i++){
	  	if(fld.options[i].selected == true){
			if(fld.options[i].value == OtherVal){
				otherFound  = true;
			}
		}
	}
	//' --- show/hide/empty 'Other' Textfield
	if (otherFound == true){
		oDiv.style.display = '';
    }else{
  	    ofld.value = "";
  		oDiv.style.display = 'none';
    }
  
  }

/*
' ==================================================
' === render or hide obj
' ==================================================
*/
function displayThis(obj){
	// Arguments

	var m = "";
	var o = document.getElementById(obj);
	if (o.style.display == "none"){
		o.style.display = "";
		if (arguments.length > displayThis.length){
			for(var a = displayThis.length; a < arguments.length; a++){
				m += arguments[a];	
				document.getElementById(arguments[a]).style.display = "inline";
			}
		}

		
	}else{
		o.style.display = "none";

		if (arguments.length > displayThis.length){
			for(var a = displayThis.length; a < arguments.length; a++){
				m += arguments[a];	
				document.getElementById(arguments[a]).style.display = "none";
			}
		}

	}

	return true;
}

// ***End library code***


// *********************** ORDER ***************************

	function order(what_)                  
		{ 	var msg = "";
			var s = "";
			var p2_ID = document.form1[what_].value;
			var qty =  document.form1["qty_" + p2_ID].value;
			//msg += "what_: " + what_ + " = " + form1[what_].value + "\n";
			//msg += "p2_ID : " + p2_ID + "\n";
			//msg += "qty : " + qty + "\n";
			//alert(msg);
			// create query string
			s = "?p2_ID=" + p2_ID + "&qty=" + qty + "&fr=prod2"
			//alert(s);
			parent.frames["data1"].location.href = "basket1.htm" + s
			//document.form1[what_].value="true";  
			//document.form1.s u b m i t ( );  
			
		 	return(true);      
		}

	var Order_what = "" // global variable that contains Order number
	function select_list(what_,height_,width_)                  
		{ 
			var res = true
//			makeNewWindow('content1_edit_tips.htm','MsgWin','resizable=yes,scrollbars=yes,status=no,width=700,height=500')
			makeNewWindow(what_,'MsgWin','resizable=yes,scrollbars=yes,status=yes,width='+width_+',height='+ height_)
		 	return(true)                      
		}


	function disp_status(status_msg) {
	//	DefaultStatus = status_msg;
		try{
			window.status = status_msg;
		}catch(e){}
		return true;
	}


// *********************** NEW BROWSER WINDOW ***************************

// Global variable for subwindow reference
var newWindow
// Version flag for old browsers (Nav2/IE3)
var oldStuff = parseInt(navigator.appversion) < 3
// Generate and fill the new window
function makeNewWindow(filename_,winName_,features_,theMsg_) {
	var filename = arguments[0];    	//' --- filename to call
	var winName  = arguments[1];		//' --- window name
	var features = arguments[2];		//' --- window features
	var theMsg   = arguments[3];		//' --- the message to display (if any)
	var OtherVal;
	var x = 0, y = 0;
	//' --- get more arguments of the function
	if (arguments.length > 4){x = arguments[4];} 				//' --- x - position of window (optional)
	if (arguments.length > 5){y = arguments[5];} 				//' --- y - position of window (optional)
		
	//alert(arguments.length + " x: " + x + " y: " + y);
	// make sure it isn't already opened

		newWindow = window.open(filename,winName,features)
		// handle Navigator 2, which doesn't have an opener property
		newWindow.moveTo(x,y);

		if (!newWindow.opener) {
			newWindow.opener = window
		}
		// delay writing until window exists in IE3
	if (!oldStuff) {
		// window is already open so bring it to the front
		var timerID;
		clearTimeout(timerID);
		timerID = setTimeout("newWindow.focus()",250);
		//alert("newWindow: " + newWindow);
		
	}
}


function writeToWindow() {
	var newContent
	// assemble content for new window
}
		

function Validate(form_, command_)
{
	//alert("form_ " + form_);
	var f = eval("document." + form_)
	document.forms[form_].command.value = command_

	f.submit()
return(true);
}

// *********************** DIV behaviour ***************************
/* IE only */

function hideShowDIV(elName, vis){
	var objElement
	var d = document
	if (parseInt(navigator.appVersion) > 4) {		
		objElement = d.getElementById(elName);
	}else{
		objElement = d.all[elName];
	}
	
	//objElement.style.height = 0;
	//objElement.style.visibility = vis;
	objElement.style.display = vis;


}


/*
' ===================================================================
' === FUN STUFF 
' ===================================================================
'
' -------------------------------------------------------------------
' --- Menu Shadow (Shadow for Menu DIV)
' -------------------------------------------------------------------
' if you dont want to use the shadow remove this script block and
' these lines in function displMenu():
'	// --- create shadow ----
'	var res = makeRectangularDropShadow(M1, "#cccccc", 3)
'	global.fo_currentMenu = M1;
' -------------------------------------------------------------------
*/
var global = window.document
global.fo_currentMenu = null
global.fo_shadows = new Array

function makeRectangularDropShadow(el, color, size)
{
	if (parseInt(navigator.appVersion) > 4) {

		var res = cleanUpShadow() //' --- clean up existing shadow first
	
		var i;
		for (i=size; i>0; i--)
		{
			var rect = document.createElement('div');
			var rs = rect.style
			rs.position = 'absolute';
			rs.left = (el.style.posLeft + i) + 'px';
			rs.top = (el.style.posTop + i) + 'px';
			rs.width = el.offsetWidth + 'px';
			rs.height = el.offsetHeight + 'px';
			rs.zIndex = el.style.zIndex - i;
			rs.backgroundColor = color;
			var opacity = 1 - i / (i + 1);
			rs.filter = 'alpha(opacity=' + (100 * opacity) + ')';
			el.insertAdjacentElement('afterEnd', rect);
			global.fo_shadows[global.fo_shadows.length] = rect;
		}
    } //'if (parseInt(navigator.appVersion) > 4)
}

function cleanUpShadow(){

	if (global.fo_currentMenu)
	{
		for (i=0; i<global.fo_shadows.length; i++)
		global.fo_shadows[i].removeNode(true);
	}
}

//window.onLoad="MM_preloadImages('images/01_Home_Over.gif','images/02_Catalogue_Over.gif','images/03_Departments_Over.gif','images/04_StoreInfo_Over.gif','images/05_Community_Over.gif','images/06_AboutKmart_Over.gif','images/07_ContactUs_Over.gif','images/08_MyKmart_Over.gif')"
function MM_findObj(n, d) { //v3.0
  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); 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 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_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];}}
}


//-->
