var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var item
var cache = new Array();
var ext = ".aspx"
var stack = new Array();
var stackptr;
var theObj="";
var backkey = 0;
var ap = ""
var onloads = new Array();
var paneltoggled = 0;
var winopen = 0;
var AjaxinputValidates;
var dunit = 0;


var isFirefox = navigator.userAgent.indexOf("Firefox") != -1;
var isIE = navigator.userAgent.indexOf("MSIE") != -1;
var isOpera = navigator.userAgent.indexOf("Opera") != -1;
var isSafari = navigator.userAgent.indexOf("AppleWebKit") != -1;


var tmp = navigator.appName == 'Microsoft Internet Explorer' && navigator.userAgent.indexOf('Opera') < 1 ? 1 : 0;
if(tmp) var isIE = document.namespaces ? 1 : 0;

var op = navigator.userAgent.indexOf('pera')
try {
	if (teller == 'yes') { //teller exposed
		async = 'false';
	}
} catch (e) {} finally{}


function postAlert(msg) {
debug(msg,"true");
}         

function showWindow() {
 if (newWindow == null) {
  newWindow = new Window('new_window', {className: 'dialog',width:400, height:250, right:4, bottom:42, zIndex:1000, opacity:1, showEffect: Element.show, resizable: true, title: "newWindow"})
  newWindow.getContent().innerHTML = "<style>#new_window</style> <div id='newWin'></div>";
  
 }
 newWindow.show()
}

 function onKeyDown(event)
    {
        if (event.keyCode == 123) {
            if (showDebug) {
                
                showExtendedDebug();
                postAlert("open debugger");
                
            }
        }
        else
            return;
        
        cancelEvent(event);
    }
    
    
    
      function addEvent(object, name, handler)
    {
        if (document.all)
            object.attachEvent("on"+name, handler);
        else
            object.addEventListener(name, handler, false);
    }
    
    function removeEvent(object, name, handler)
    {
        if (document.all)
            object.detachEvent("on"+name, handler);
        else
            object.removeEventListener(name, handler, false);
    }
    
    function cancelEvent(event)
    {
        if (document.all)
            event.cancelBubble = true;
        else
            event.stopPropagation();        
    }

    function onError(msg, href, lineNo)
    {
        var html = [];
        
        var lastSlash = href.lastIndexOf("/");
        var fileName = lastSlash == -1 ? href : href.substr(lastSlash+1);
        
        html.push(
            '<span class="errorMessage">', msg, '</span>', 
            '<div class="objectBox-sourceLink">', fileName, ' (line ', lineNo, ')</div>'
        );
        
        postAlert(html);
    };
    
    
    window.onerror = onError;
    addEvent(document, isIE || isSafari ? "keydown" : "keypress", onKeyDown);
    
    if (document.documentElement.getAttribute("debug") == "true") showDebug();    
                     
function historyChange(newLocation,  historyData) {
	var historyMsg = historyData;
            
	if (newLocation == "complexObject") {
		historyMsg =JSON.stringify(historyData);          
	}
	// postAlert("<b>A history change has occurred:</b> newLocation="+newLocation + ", historyData="+historyMsg);
}
         

var Rules = {
'#menu li:click'			: function(element, event) {menuli(lookfor("LI",element)); Event.stop(event);},
'#checkout:click'			: function(element, event) {checkout(element); Event.stop(event);},
'#basketclear:click'		: function(element, event) {basketclear(element); Event.stop(event);},
'#collection:click'			: function(element, event) {redirect("basket"); Event.stop(event);},
'.pane:click'				: function(element, event) {togglepanel(element);}
}

if( typeof Array.prototype.push == 'undefined' )
{
  Array.prototype.push = function( element ) { this[this.length] = element; }
}
if( typeof Array.prototype.pop == 'undefined' )
{
  Array.prototype.pop = function () 
  { 
    var last = this[ this.length - 1 ]; this.length--; return last; 
  }
}

if (stackptr > 0 ) restoreitem();


var ag = window.navigator.userAgent.indexOf("MSIE") > 0;
var op = window.navigator.userAgent.indexOf("pera") > 0;

if (! ag) {
	if (!op) {
	HTMLElement.prototype.__defineGetter__("innerText", 
				function () { return(this.textContent); });
	HTMLElement.prototype.__defineSetter__("innerText", 
				function (txt) { this.textContent = txt; });
              
	var _emptyTags = {
	"IMG":   true,
	"BR":    true,
	"INPUT": true,
	"META":  true,
	"LINK":  true,
	"PARAM": true,
	"HR":    true
	};

	HTMLElement.prototype.__defineGetter__("outerHTML", function () {
	var attrs = this.attributes;
	var str = "<" + this.tagName;
	for (var i = 0; i < attrs.length; i++)
		str += " " + attrs[i].name + "=\"" + attrs[i].value + "\"";

	if (_emptyTags[this.tagName])
		return str + ">";

	return str + ">" + this.innerHTML + "</" + this.tagName + ">";
	
	});

	HTMLElement.prototype.__defineSetter__("outerHTML", function (sHTML) {
	var r = this.ownerDocument.createRange();
	r.setStartBefore(this);
	var df = r.createContextualFragment(sHTML);
	this.parentNode.replaceChild(df, this);
	});
	}         
}


 function cancelEvent(event)
    {
        if (document.all)
            event.cancelBubble = true;
        else
            event.stopPropagation();        
    }


function cancelBubble() {

    
        if (window.event) {
            cancelEvent(window.event);
             //window.event.returnValue = false;
        }
    
}

function noPostBack(sNewFormAction)
{
    if(document.layers) //The browser is Netscape 4
    {
        document.layers['Content'].document.forms[0].__VIEWSTATE.name = 
                                                           'NOVIEWSTATE';
       // document.layers['Content'].document.forms[0].action = sNewFormAction;
    }
    else //It is some other browser that understands the DOM
    {
        // document.forms[0].action = sNewFormAction;
        document.forms[0].__VIEWSTATE.name = 'NOVIEWSTATE';
    }
}

function atobs() {


/***********************************************
* Easy Email Scrambler script- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
var maildivider="(at)" //enter divider you use to divide your email address strings

for (i=0; i<=(document.links.length-1); i++){
if (document.links[i].href.indexOf(maildivider)!=-1)
document.links[i].href=document.links[i].href.split(maildivider)[0]+"@"+document.links[i].href.split(maildivider)[1]
}


}

function redirect(where) {
window.location = "construct.aspx?name=" + where;
};

function switchimage( loc, newimg ) {

$(loc).src = newimg;

}

function wincreateframe (url,xsize,ysize){

if (xsize == undefined ) xsize = 600
if (isIE && ysize == undefined ) ysize = 400  // change to 600 to deepen

$('dwindowcontent').innerHTML= "Loading.."
$('dwindowcontent').innerHTML= "<iframe id=cframe src='' width=100% height=100%></iframe>"

if (ns6) window.onload=new Function('loadwindow(url,xsize,ysize)')
else
loadwindow(url,xsize,ysize)
	
}
function wincreatedivid(divid,xsize,ysize){
if (xsize == undefined ) xsize = 600
if (isIE && ysize == undefined ) ysize = 400  // change to 600 to deepen
$('dwindowcontent').innerHTML= $(divid).innerHTML
loadwindow("",xsize,ysize)
}

function wincreate(url,xsize,ysize){

if (xsize == undefined ) xsize = 600
if (isIE && ysize == undefined ) ysize = 400  // change to 600 to deepen

loadwindow("",xsize,ysize)

//ajaxwait('dwindowcontent')
var myAjax = new Ajax.Updater({success: 'dwindowcontent' ,failure: 'dwindowcontent'},url, {method: 'get',  asynchronous: 'true', evalScripts: 'true'});
cancelBubble();		
}

function corefinal() {

var myform = new Array;
   try {
	     
	myform = document.forms[0].innerHTML.split('<FORM');
	
	if (myform.length> 1 ) {
		var actions = new Array;
		actions = myform[1].split('action=')
		actions = actions[1].split(' ')
		actions = actions[0].split('"')
	   
		noPostBack(actions[1]);
   }
   
    } catch(e) {};


var ended = 1;

};

function starthistory() {

dhtmlHistory.initialize();
dhtmlHistory.addListener(historyChange);
dhtmlHistory.add("1", "Hello World " + "Data");
}

function formcheck (){
if(isFormValid()) document.forms[0].submit(); else { alert('incomplete input');return false; }
}
function updateloads() {


for ( var i = 0 ; i < onloads.length ; i++ ) onloads[i]();
	  initFormValidation();
	      try {
	      if (winopen ==0){
			dosifr();
	      }
	      } catch(e) {};
}

function updatecore() {
EventSelectors.start(Rules);
updateloads();
elements = document.getElementsByClassName('param');
try {
	ext ="." + elements[0].id;
} catch (e){}
do {
	counted = updatetags();
	} while (counted > 0)
	restartWindow();
}
function updatetags() {
var counted = 0;
	elements = document.getElementsByClassName('load');
	for (i = 0;i<elements.length; i++) {
		backkey = 1;
		var mytemplate = '';
		tag =elements[i].id;
		tobj = elements[i];
		myparam = elements[i].outerHTML
		
		var cached = new Array
		cached = myparam.split('cache="no"')
		var link = new Array;
		link = myparam.split('template');
		if (link.length > 1 ){
			var link2 = new Array;
			link2 = link[1].split('"');
			mytemplate = link2[1];
		}
		if (mytemplate == '') {
			mytemplate = tag;
		};
		wanted = 1;
		for (j = 0; j<cache.length; j++){
			if (cache[j]==tag+mytemplate) {wanted = 0; j=cache.length;}
		}
		if (wanted == 1) {
			cache[cache.length]=tag+mytemplate;
			page ="loader" + ext +"?load=" +mytemplate + "&" + "divid=" + tag
			theparam = '';
			var link3 = new Array;
			link3 = myparam.split('param');
			if (link3.length > 1 ){
				var link2 = new Array;
				link2 = link3[1].split('"');
				theparam = link2[1];
			}
			if (theparam != '') {
				var link4 = new Array;
				link4 = theparam.split("=");
				if (link4.length == 1) {
					theparam = "param=" + theparam;
				}
			}
			
			if (theparam != "") {
				page = page + "&" + theparam
			}
			if (cached.length>1) {
				page = page + "&" + "cached=n"
			};
			if (tobj.id!='duckshoot') {
				tobj.innerHTML="<img src=" + loaderroot +"/ajax-loader.gif>";
			};
			page = page + "&" + "defaultitemlistid=" +defaultitemlistid
			var myAjax = new Ajax.Updater(tag, page,{method: 'get',  asynchronous: async, evalScripts:'true'})
			counted = counted + 1;
		}
	}
	EventSelectors.assign(Rules);
	initFormValidation(); 
	return counted;
}



function classclicked(element) {

html=element.outerHTML.toLowerCase();
classclickedh(html);
};

function classclickedh(html){


	html =noamp(html)
	var link = new Array;
	link = html.split('loader.aspx?');
	
	var link2 = new Array;
	link2= link[1].split('"');
	ap = "loader.aspx?slice=yes&" + link2[0]
	ajaxwait('dwindowcontent')

	wincreate(ap);
	
};

function ajaxwait(div) {
if ($(div) != undefined) {
	$(div).innerHTML="<img src=" + loaderroot +"/ajax-loader.gif>";
}
cancelBubble();
}

function addtocollection(html) {
	html = html.outerHTML;
	html =noamp(html)
	var ix = 3;
	var link = new Array;
	link = html.split('"');
	
	if ($('collection') != undefined) {
		ajaxwait('collection')
		if (ap !='') {
			ajaxwait('dwindowcontent')
		}
	}
	for (i=0; i<link.length;i++) {
	 if (link[i].indexOf("lection.aspx?") > 0) {
	    ix = i;
	    i = link.length;
	 }
	}
	var myAjax2 = new Ajax.Updater(	{success: 'collection'},link[ix], {method: 'get',  asynchronous: 'true', evalScripts:'true'});
	if ($('basket') != undefined){
	
		ajaxwait('basket')
		var myAjax3 = new Ajax.Updater(	{success: 'basket'},"loader.aspx?load=basket", {method: 'get',  asynchronous: 'false', evalScripts:'true'});	
		ajaxwait('basketclosure')
		var myAjax4 = new Ajax.Updater(	{success: 'basketclosure'},"loader.aspx?load=basketclosure", {method: 'get',  asynchronous: 'false', evalScripts:'true'});	
	}
	
	if (ap !='') {
		ajaxwait('dwindowcontent')
		var myAjax = new Ajax.Updater(	{success: 'dwindowcontent'},ap, {method: 'get',  asynchronous: 'true', evalScripts:'true'});
	}
	cancelBubble();
}

	



function addtocollectionclass(html) {

	addtocollection(html)
	ajaxwait('basket')
	ajaxwait('basketclosure')
	var myAjax2 = new Ajax.Updater(	{success: 'basket'},"loader" + ext +"?load=basket", {method: 'get',  asynchronous: 'true', evalScripts:'true'});
	var myAjax3 = new Ajax.Updater(	{success: 'basketclosure'},"loader" + ext +"?load=basketclosure", {method: 'get',  asynchronous: 'true', evalScripts:'true'});
}


function checkout(html) {
	html = html.outerHTML;
	html =noamp(html)
	var link = new Array;
	link = html.split('"');
	ajaxwait('content')
	var myAjax = new Ajax.Updater(	{success: 'content'},link[1], {method: 'get',  asynchronous: 'true', evalScripts:'true'});
	
}
function basketclear(html) {
	html = html.outerHTML;
	html =noamp(html)
	var link = new Array;
	link = html.split('"');
	ajaxwait('basket')
	var myAjax = new Ajax.Updater(	{success: 'basket'},link[1], {method: 'get',  asynchronous: 'false', evalScripts:'true'});
	$('basketclosure').innerHTML= ""
}


function noamp(instr)
{
var ckstring ="";
var outstring = ""

ckstring = instr
while (ckstring != outstring){
	outstring = ckstring.replace("&amp;","&")
	ckstring = ckstring.replace("&amp;","&")
	ckstring = ckstring.replace("&amp;","&")
};

return outstring;
}


function menuli(html) {

if (paneltoggled ==0) {
	html =noamp(html)

	
	
	var link = new Array;
	link = html.split('"');
	var link2 = new Array;
	link2 = link[1].split('id=');
	item = link2[1]
	
	var gotol = link[1]
	ajaxwait('detail')
	ajaxwait('itemlistloader')
	var myAjax2 = new Ajax.Updater(	{success: 'detail'},'loader'+ ext + '?load=detail&id=' + item , {method: 'get',  asynchronous: 'false', evalScripts:'true'});
	var myAjax = new Ajax.Updater(	{success: 'itemlistloader'},gotol, {method: 'get',  asynchronous: 'true', evalScripts:'true'});
	duckshoot();
	}
	paneltoggled = 0;
	
}
function itemlistli(html) {
	var link = new Array;
	stack[stackptr++]=html;
	link = html.split('clickwindowli')
	if (link.length != 2) {
		switchtoitem(html);
	} else {
		classclickedh(html);	
	};
}

function backoneitem(){
	if (stackptr > 1 ){
		switchtoitem(stack[(--stackptr)-1]);	
	}
}
function forwardoneitem(){
	if (stackptr < stack.length ){
		switchtoitem(stack[(++stackptr)-1]);	
	}
}
function restoreitem(){
	if (stackptr > 0  ){
		switchtoitem(stack[(stackptr)]);	
	}
}
function lookfor(TAG,obj){



html = obj.outerHTML;

return html;

}

function lookfor2(TAG,obj){


if (ag) {

try {

// look for an <A href> tag, inside another 
while (obj.tagName != TAG) {
	obj=obj.parentElement;
}

html = obj.innerHTML;
}
catch (e) { html = obj.outerHTML}
} else
{
html = obj.outerHTML;
}
var sp = new Array;
	sp =html.split("<A")
return "<A" + sp[1]
};


function lookforobj(TAG,obj){
while (obj.tagName != TAG) {
	obj=obj.parentElement;
}
return obj
};


function switchitemli(obj) {

	obj = lookforobj("LI",obj)
	html = obj.innerHTML

	
	var link = new Array;

	link = html.split('clickwindowli')
;
	if (link.length == 1) {
		html =noamp(html)
	
	
		var link = new Array;
		link = html.split('sub');

	
		var link1 = new Array;
		link1 = link[1].split("id=");
	
		var link2= new Array;
		link2 = html.split("redir=")
		
	
		if (link2.length == 1) {
			ajaxwait('detail')
			var myAjax = new Ajax.Updater(	{success: 'detail'},link[1], {method: 'get',  asynchronous: 'true', evalScripts:'true'});
			duckshoot();
		} 
		
		else {
			var link3 = new Array;
			link3 = link1[1].split("&")
		
			menuli('<a href="loader.aspx?load=itemlist&amp;template=itemlist&amp;id=' + link3[0] + '">link</a>');
		};

	} 
	else {
		classclickedh(html);	
	};
	
}
function switchtoitem(html){

	html =noamp(html)
	var link = new Array;
	link = html.split('"');
	
	var link1 = new Array;
	link1 = link[1].split("id=");
	
	var link2= new Array;
	link2 = html.split("redir=")
	
	if (link2.length == 1) {
		ajaxwait('detail')
		var myAjax = new Ajax.Updater(	{success: 'detail'},link[1], {method: 'get',  asynchronous: 'true', evalScripts:'true'});
		duckshoot();
	} else {
	var link3 = new Array;
		link3 = link1[1].split("&")
		
		menuli('<a href="loader.aspx?load=itemlist&amp;template=itemlist&amp;id=' + link3[0] + '">link</a>');
	};
}

function ajaxcall(divname,html) {
	html =noamp(html);
	ajaxwait(divname)
	var myAjax = new Ajax.Updater(	{failure: divname, success: divname},html, {method: 'get',  asynchronous: 'true', evalScripts:'true'});
};



function duckshoot(){
	//ajaxwait('duckshoot')
	
	var myAjax = new Ajax.Updater(	{success: 'duckshoot'},'loader' + ext +'?load=randomlist&divid=duckshoot', {method: 'get',  asynchronous: 'true', evalScripts:'true'});
}

function hideMe(container) {
  document.getElementById(container).style.display="none";
}
function showMe(container) {
  document.getElementById(container).style.display="";
}
// Get the computed css property
function getStyle( element, cssRule )
{
  if( document.defaultView && document.defaultView.getComputedStyle )
  {
    var value = document.defaultView.getComputedStyle( element, '' ).getPropertyValue( 
      cssRule.replace( /[A-Z]/g, function( match, char ) 
      { 
        return "-" + char.toLowerCase(); 
      } ) 
    );
  }
  else if ( element.currentStyle ) var value = element.currentStyle[ cssRule ];
  else                             var value = false;
  return value;
}

// Set a style property
function setStyle( element, cssRule, value )
{
  var original = getStyle( element, cssRule );
  if ( !element.styleHistory )            
    element.styleHistory = new Array();
  if ( !element.styleHistory[ cssRule ] ) 
    element.styleHistory[ cssRule ] = new Array();
  element.styleHistory[ cssRule ].push( original );
  element.style[ cssRule ] = value;
  return value;
}

// Undo a style property change
function undoSetStyle( element, cssRule )
{
  if ( 
    this.styleHistory && 
    this.styleHistory[ cssRule ] && this.styleHistory[ cssRule ].length 
  ) {
    var oldValue = this.styleHistory[ cssRule ].pop();
    this.style[ cssRule ] = oldValue;
  }
}

// Revert one or more style properties
function revertStyle( element, cssRules )
{
  var stylesChanged = 0;
  if( element.styleHistory )
  {
    if ( cssRules == '*' ) 
    { 
      cssRules = new Array(); 
      for( var a in element.styleHistory ) cssRules.push( a ); 
    }
    else if ( typeof cssRules != "Array" ) cssRules = Array( cssRules );

    for( var a = 0; a < cssRules.length; a++ )
    {
      var cssRule = cssRules[a];
      if ( 
        element.styleHistory[ cssRules[a] ] && 
        element.styleHistory[ cssRules[a] ][0] 
      ) {
        element.style[ cssRules[a] ] = element.styleHistory[ cssRules[a] ][0];
        element.styleHistory[ cssRules[a] ] = new Array();
        stylesChanged++;
      }
    }
  }
  return stylesChanged;
}

function togglepanel(obj) {

//menuli(lookfor("LI",obj));

which = obj.parentElement;

which = "panel"+which.id.substr(4)

var w = mytoggle(which)
if (w == '') {
	obj.src = rootimages + 'minus.gif';
} else {
	obj.src= rootimages + 'plus.gif';
}

paneltoggled=1;
};




function mytoggle(obj) {
	
	el = document.getElementById(obj)
	
	if ( el.style.display != 'none' ) {
			el.style.display = 'none';
	}
	else {
		el.style.display = '';
	}
	return el.style.display;
}



/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Public Domain (Thanks to Dustin Diaz) :: http://www.dustindiaz.com/top-ten-javascript/ */

function getCookie( name ) {
  var start = document.cookie.indexOf( name + "=" );
  var len = start + name.length + 1;
  if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) {
    return null;
  }
  if ( start == -1 ) return null;
  var end = document.cookie.indexOf( ";", len );
  if ( end == -1 ) end = document.cookie.length;
  return unescape( document.cookie.substring( len, end ) );
}

function setCookie( name, value, expires, path, domain, secure ) {
  var today = new Date();
  today.setTime( today.getTime() );
  if ( expires ) {
    expires = expires * 1000 * 60 * 60 * 24;
  }
  var expires_date = new Date( today.getTime() + (expires) );
  document.cookie = name+"="+escape( value ) +
    ( ( expires ) ? ";expires="+expires_date.toGMTString() : "" ) + //expires.toGMTString()
    ( ( path ) ? ";path=" + path : "" ) +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}

function deleteCookie( name, path, domain ) {
  if ( getCookie( name ) ) document.cookie = name + "=" +
    ( ( path ) ? ";path=" + path : "") +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}



//DHTML Window script- Copyright Dynamic Drive (http://www.dynamicdrive.com)
//For full source code, documentation, and terms of usage,
//Visit http://www.dynamicdrive.com/dynamicindex9/dhtmlwindow.htm

var dragapproved=false
var minrestore=0
var initialwidth,initialheight
var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all

function iecompattest(){
return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function drag_drop(e){
if (ie5&&dragapproved&&event.button==1){
document.getElementById("dwindow").style.left=tempx+event.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+event.clientY-offsety+"px"
}
else if (ns6&&dragapproved){
document.getElementById("dwindow").style.left=tempx+e.clientX-offsetx+"px"
document.getElementById("dwindow").style.top=tempy+e.clientY-offsety+"px"
}
}

function initializedrag(e){
offsetx=ie5? event.clientX : e.clientX
offsety=ie5? event.clientY : e.clientY
document.getElementById("dwindowcontent").style.display="none" //extra
tempx=parseInt(document.getElementById("dwindow").style.left)
tempy=parseInt(document.getElementById("dwindow").style.top)

dragapproved=true
document.getElementById("dwindow").onmousemove=drag_drop
}

function loadwindow(url,width,height){
winopen=1;


try {
	sIFR.rollback()		
} 
catch (e) {} finally{}



if (!ie5&&!ns6)
window.open(url,"","width=width,height=height,scrollbars=1")
else{

if(initialwidth == null) initialwidth = 0
if(initialheight == null) initialheight = 0

var el = document.getElementById("dwindow");
if (el) {
document.getElementById("dwindow").style.width=initialwidth=width+"px"
document.getElementById("dwindow").style.height=initialheight=height+"px"
document.getElementById("dwindow").style.left="30px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset*1+30+"px" : iecompattest().scrollTop*1+30+"px"
if (url!=""){
document.getElementById("cframe").src=url
}
document.getElementById("dwindow").style.display=''
}
}
}

function maximize(){
if (minrestore==0){
minrestore=1 //maximize window
document.getElementById("maxname").setAttribute("src",rootimages + "restore.gif")
document.getElementById("dwindow").style.width=ns6? window.innerWidth-20+"px" : iecompattest().clientWidth+"px"
document.getElementById("dwindow").style.height=ns6? window.innerHeight-20+"px" : iecompattest().clientHeight+"px"
}
else{
minrestore=0 //restore window
document.getElementById("maxname").setAttribute("src",rootimages + "max.gif")
document.getElementById("dwindow").style.width=initialwidth
document.getElementById("dwindow").style.height=initialheight
}
document.getElementById("dwindow").style.left=ns6? window.pageXOffset+"px" : iecompattest().scrollLeft+"px"
document.getElementById("dwindow").style.top=ns6? window.pageYOffset+"px" : iecompattest().scrollTop+"px"
}

function closeit(){


//$('dwindowcontent').innerHTML= "Loading.."
document.getElementById("dwindow").style.display="none"
ap = ''
winopen = 0;
updateloads();
cancelBubble();
}

function stopdrag(){
dragapproved=false;
document.getElementById("dwindow").onmousemove=null;
document.getElementById("dwindowcontent").style.display="" //extra
}


/************************************************************************************************************
(C) www.dhtmlgoodies.com, February 2006

This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	

Terms of use:
You are free to use this script as long as the copyright message is kept intact. However, you may not
redistribute, sell or repost it without our permission.

Thank you!

www.dhtmlgoodies.com
Alf Magne Kalleland

************************************************************************************************************/	
	
	
// Patterns
var formValidationMasks = new Array();
formValidationMasks['email'] = /\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/gi;	// Email
formValidationMasks['numeric'] = /^[0-9]+$/gi;	// Numeric
formValidationMasks['zip'] = /^[0-9]{5}\-[0-9]{4}$/gi;	// Numeric

var formElementArray = new Array();

function validateInputwithAjax(e, inputObj) {



try {
	validateInput(e,inputObj);
} catch (e) {} finally{}

if(!inputObj)inputObj = this;		
	var inputValidates = true;
	AjaxinputValidates = true;
	if (inputObj.parentNode.className!='invalidInput') {
	
		var tmpAjax = formElementArray[inputObj.name]['ajax'];
		url = "loader.aspx?kind=udf&udf=" + tmpAjax + "&param='" + inputObj.value+"'"
		
		if ($('ajaxresult')==undefined) {
		
			var div = $E({ tag:'div', id:'ajaxresult'})
			document.appendChild(div);
		};
		
		var myAjax = new Ajax.Updater({success: 'ajaxresult'},url, {method: 'get',  asynchronous: 'false', evalScripts:'true'});	
		
			
		if(AjaxinputValidates){
			inputObj.parentNode.className='validInput';
		}else{
			inputObj.parentNode.className='invalidInput'
		}
	}
};


function validateInput(e,inputObj)
{
	if(!inputObj)inputObj = this;		
	var inputValidates = true;
	
	if(formElementArray[inputObj.name]['required'] && inputObj.tagName=='INPUT' && inputObj.value.length==0)inputValidates = false;
	if(formElementArray[inputObj.name]['required'] && inputObj.tagName=='SELECT' && inputObj.selectedIndex==0){
		inputValidates = false;
	}
	if(formElementArray[inputObj.name]['mask'] && !inputObj.value.match(formValidationMasks[formElementArray[inputObj.name]['mask']]))inputValidates = false;

	if(formElementArray[inputObj.name]['freemask']){
		var tmpMask = formElementArray[inputObj.name]['freemask'];
		tmpMask = tmpMask.replace(/-/g,'\\-');
		tmpMask = tmpMask.replace(/S/g,'[A-Z]');
		tmpMask = tmpMask.replace(/N/g,'[0-9]');
		tmpMask = eval("/^" + tmpMask + "$/gi");
		if(!inputObj.value.match(tmpMask))inputValidates = false
	}	
	
	if(formElementArray[inputObj.name]['regexpPattern']){
		var tmpMask = eval(formElementArray[inputObj.name]['regexpPattern']);
		if(!inputObj.value.match(tmpMask))inputValidates = false
	}
	if(!formElementArray[inputObj.name]['required'] && inputObj.value.length==0 && inputObj.tagName=='INPUT')inputValidates = true;
	
	
	if(inputValidates){
		inputObj.parentNode.className='validInput';
	}else{
		inputObj.parentNode.className='invalidInput'
	}
}

function isFormValid()
{
	var divs = document.getElementsByTagName('DIV');
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='invalidInput')return false;
	}
	return true;	
}




function initFormValidation()
{
	var inputFields = document.getElementsByTagName('INPUT');
	var selectBoxes = document.getElementsByTagName('SELECT');
	var ajax ;
	var inputs = new Array();
	
	var op = window.navigator.userAgent.indexOf("Opera") > -1;
	
	for(var no=0;no<inputFields.length;no++){
		inputs[inputs.length] = inputFields[no];
		
	}	
	for(var no=0;no<selectBoxes.length;no++){
		inputs[inputs.length] = selectBoxes[no];
		
	}
	
	for(var no=0;no<inputs.length;no++){
		var required = inputs[no].getAttribute('required');
		if(!required)required = inputs[no].required;		
		
		var mask = inputs[no].getAttribute('mask');
		if(!mask)mask = inputs[no].mask;
		
		var freemask = inputs[no].getAttribute('freemask');
		if(!freemask)freemask = inputs[no].freemask;
		
		var regexpPattern = inputs[no].getAttribute('regexpPattern');
		if(!regexpPattern)regexpPattern = inputs[no].regexpPattern;
		ajax = inputs[no].getAttribute('ajax');
		

		
		if (inputs[no].parentNode.className != 'invalidInput'){
			if (inputs[no].parentNode.className != 'validInput'){
				var div = document.createElement('DIV');
				div.className = 'invalidInput';
				inputs[no].parentNode.insertBefore(div,inputs[no]);
				div.appendChild(inputs[no]);
				div.style.width = inputs[no].offsetWidth + 'px';
				
				formElementArray[inputs[no].name] = new Array();
				formElementArray[inputs[no].name]['ajax']=ajax;
				
				if (!op) {
				if (ajax !=null) {
					inputs[no].onblur = validateInputwithAjax;
					}
				else {
					inputs[no].onblur = validateInput;
				};
				} else {
					inputs[no].onblur = validateInput;
				}
				inputs[no].onchange = validateInput;
				inputs[no].onpaste = validateInput;
				inputs[no].onkeyup = validateInput;
				
				formElementArray[inputs[no].name]['mask'] = mask;
				formElementArray[inputs[no].name]['freemask'] = freemask;
				formElementArray[inputs[no].name]['required'] = required;
				formElementArray[inputs[no].name]['regexpPattern'] = regexpPattern;
				
			validateInput(false,inputs[no]);
			}
		}		
	}	
}


/**
 * document.createElement convenience wrapper
 *
 * The data parameter is an object that must have the "tag" key, containing
 * a string with the tagname of the element to create.  It can optionally have
 * a "children" key which can be: a string, "data" object, or an array of "data"
 * objects to append to this element as children.  Any other key is taken as an
 * attribute to be applied to this tag.
 *
 * Release homepage:
 * http://www.arantius.com/article/dollar+e
 *
 * Available under an MIT license:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * @param {Object} data The data representing the element to create
 * @return {Element} The element created.
 
 usage:
 
 var element = $E({
  tag:'div',
    className:'toolGroup',
    id:'toolGroup_1',
    children:{
        tag:'div',
        className:'roundBarTop',
        children:[{
            tag:'div',
            className:'leftEdge'
        },{
            tag:'div',
            className:'rightEdge'
        },{
            tag:'div',
            className:'heading',
            children:[{
                tag:'a',
                className:'collapser'
            },
                'Group Heading'
            ]
        }]
    }
});
 
 
 
 */
function $E(data) {
	var el;
	if ('string'==typeof data) {
		el=document.createTextNode(data);
	} else {
		//create the element
		el=document.createElement(data.tag);
		delete(data.tag);

		//append the children
		if ('undefined'!=typeof data.children) {
			if ('string'==typeof data.children ||
				'undefined'==typeof data.children.length
			) {
				//strings and single elements
				el.appendChild($E(data.children));
			} else {
				//arrays of elements
				for (var i=0, child=null; 'undefined'!=typeof (child=data.children[i]); i++) {
					el.appendChild($E(child));
				}
			}
			delete(data.children);
		}

		//any other data is attributes
		for (attr in data) {
			el[attr]=data[attr];
		}
	}

	return el;
}

function unloadJS(scriptName) {
  var head = document.getElementsByTagName('head').item(0);
  var js = document.getElementById(scriptName);
  js.parentNode.removeChild(js);
}

function unloadAllJS() {
  var jsArray = new Array();
  jsArray = document.getElementsByTagName('script');
  for (i = 0; i < jsArray.length; i++){
    if (jsArray[i].id){
      unloadJS(jsArray[i].id)
    }else{
      jsArray[i].parentNode.removeChild(jsArray[i]);
    }
  }        
}

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: J Wynia. | http://www.wynia.org/ */
// Change the domain and path below to match where your scripts are kept.
var $js_path = "http://" + window.location.hostname + "/" + loadedfrom + "/loader.aspx?kind=js&load=";

//$js_path = "";
function js_include($script){
  var script = document.createElement('script');
  script.src = $js_path + $script;
  script.type = 'text/javascript';
  var head = document.getElementsByTagName('head').item(0);
  head.appendChild(script);
}

// Enter the script files here
//js_include("prototype.js");
//js_include("scriptaculous.js");


function restartWindow () {
var winOnload = window.onload;
if(winOnload) winOnload();
}


function fav() {
var newT = document.createTextNode('Add to Favourites');
var s = document.getElementById('fav');
if (window.sidebar) {
s.appendChild(newT);
s.style.color = '#00f';
s.style.cursor = 'pointer';
s.onclick = function() {window.sidebar.addPanel(document.title,self.location,'')};
} else if (window.external) {
s.appendChild(newT);
s.style.color = '#00f';
s.style.cursor = 'pointer';
s.onclick = function() {window.external.AddFavorite(self.location,document.title)};
} else if (window.opera) {
s.appendChild(newT);
s.style.color = '#00f';
s.style.cursor = 'pointer';
s.onclick = function() {
     var e = document.createElement('a');
     e.setAttribute('href',self.location);
     e.setAttribute('title',document.title);
     e.setAttribute('rel','sidebar');
     e.click();
  }
}
}

var pageLoaded = 0;
window.onload = function() {pageLoaded = 1;}
function loaded(i,f) {
if (document.getElementById && document.getElementById(i) != null) f();
else if (!pageLoaded) setTimeout('loaded(\''+i+'\','+f+')',100);
}
loaded('fav',fav);



function cookiewindow()
{

var aCookie = itemcookieval; //getCookie("ItemIDvar")+""

if (aCookie == "") {
    aCookie = "null";
}

if(aCookie == null) {
    aCookie = "null";
}
var aParam = "";
if (aCookie != "null") {

 aParam ="loader.aspx?killcookie=yes&slice=yes&load=oneitem&id="+ aCookie
 wincreate(aParam);
 }
}

