/**
 * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
 *   legal reasons.
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}
if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}
if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}
deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){if(!document.getElementById){return;}
this.DETECT_KEY=_b?_b:"detectflash";
this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);
this.params=new Object();
this.variables=new Object();
this.attributes=new Array();
if(_1){this.setAttribute("swf",_1);}
if(id){this.setAttribute("id",id);}
if(w){this.setAttribute("width",w);}
if(h){this.setAttribute("height",h);}
if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}
this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();
if(c){this.addParam("bgcolor",c);}
var q=_8?_8:"high";
this.addParam("quality",q);
this.setAttribute("useExpressInstall",_7);
this.setAttribute("doExpressInstall",false);
var _d=(_9)?_9:window.location;
this.setAttribute("xiRedirectUrl",_d);
this.setAttribute("redirectUrl","");
if(_a){this.setAttribute("redirectUrl",_a);}};
deconcept.SWFObject.prototype={setAttribute:function(_e,_f){
this.attributes[_e]=_f;
},getAttribute:function(_10){
return this.attributes[_10];
},addParam:function(_11,_12){
this.params[_11]=_12;
},getParams:function(){
return this.params;
},addVariable:function(_13,_14){
this.variables[_13]=_14;
},getVariable:function(_15){
return this.variables[_15];
},getVariables:function(){
return this.variables;
},getVariablePairs:function(){
var _16=new Array();
var key;
var _18=this.getVariables();
for(key in _18){_16.push(key+"="+_18[key]);}
return _16;},getSWFHTML:function(){var _19="";
if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){
if(this.getAttribute("doExpressInstall")){
this.addVariable("MMplayerType","PlugIn");}
_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\"";
_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";
var _1a=this.getParams();
for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}
var _1c=this.getVariablePairs().join("&");
if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";
}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");}
_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">";
_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";
var _1d=this.getParams();
for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}
var _1f=this.getVariablePairs().join("&");
if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}
return _19;
},write:function(_20){
if(this.getAttribute("useExpressInstall")){
var _21=new deconcept.PlayerVersion([6,0,65]);
if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){
this.setAttribute("doExpressInstall",true);
this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));
document.title=document.title.slice(0,47)+" - Flash Player Installation";
this.addVariable("MMdoctitle",document.title);}}
if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){
var n=(typeof _20=="string")?document.getElementById(_20):_20;
n.innerHTML=this.getSWFHTML();return true;
}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}
return false;}};
deconcept.SWFObjectUtil.getPlayerVersion=function(){
var _23=new deconcept.PlayerVersion([0,0,0]);
if(navigator.plugins&&navigator.mimeTypes.length){
var x=navigator.plugins["Shockwave Flash"];
if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}
}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}
catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}
catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}
catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}
return _23;};
deconcept.PlayerVersion=function(_27){
this.major=_27[0]!=null?parseInt(_27[0]):0;
this.minor=_27[1]!=null?parseInt(_27[1]):0;
this.rev=_27[2]!=null?parseInt(_27[2]):0;
};
deconcept.PlayerVersion.prototype.versionIsValid=function(fv){
if(this.major<fv.major){return false;}
if(this.major>fv.major){return true;}
if(this.minor<fv.minor){return false;}
if(this.minor>fv.minor){return true;}
if(this.rev<fv.rev){
return false;
}return true;};
deconcept.util={getRequestParameter:function(_29){
var q=document.location.search||document.location.hash;
if(q){var _2b=q.substring(1).split("&");
for(var i=0;i<_2b.length;i++){
if(_2b[i].substring(0,_2b[i].indexOf("="))==_29){
return _2b[i].substring((_2b[i].indexOf("=")+1));}}}
return "";}};
deconcept.SWFObjectUtil.cleanupSWFs=function(){if(window.opera||!document.all){return;}
var _2d=document.getElementsByTagName("OBJECT");
for(var i=0;i<_2d.length;i++){_2d[i].style.display="none";for(var x in _2d[i]){
if(typeof _2d[i][x]=="function"){_2d[i][x]=function(){};}}}};
deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};
__flash_savedUnloadHandler=function(){};
if(typeof window.onunload=="function"){
var _30=window.onunload;
window.onunload=function(){
deconcept.SWFObjectUtil.cleanupSWFs();_30();};
}else{window.onunload=deconcept.SWFObjectUtil.cleanupSWFs;}};
if(typeof window.onbeforeunload=="function"){
var oldBeforeUnload=window.onbeforeunload;
window.onbeforeunload=function(){
deconcept.SWFObjectUtil.prepUnload();
oldBeforeUnload();};
}else{window.onbeforeunload=deconcept.SWFObjectUtil.prepUnload;}
if(Array.prototype.push==null){
Array.prototype.push=function(_31){
this[this.length]=_31;
return this.length;};}
var getQueryParamValue=deconcept.util.getRequestParameter;
var FlashObject=deconcept.SWFObject;
var SWFObject=deconcept.SWFObject;
/* do not change */

function init_post_request() {

  this.fn_request = false;

  if (window.XMLHttpRequest) { // Mozilla, Safari,...
    this.fn_request = new XMLHttpRequest();
    if (this.fn_request.overrideMimeType) {
      this.fn_request.overrideMimeType('text/html');
    }
  }
  else if (window.ActiveXObject) { // IE
    try {
      this.fn_request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
       try {
         this.fn_request = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (e) {}
    }
  }
  if (!this.fn_request) {
    alert('Cannot create XMLHTTP instance');
    return false;
  }

}

function post_request(obj, url, parameters) {

  obj.open('POST', url, true);
  obj.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  obj.setRequestHeader("Content-length", parameters.length);
  obj.setRequestHeader("Connection", "close");
  obj.send(parameters);

}

function build_query(frm) {
  var str = "";
  var element, i = 0;
  while ((element = document.getElementById(frm).elements[i++]) != null) {
      var qc = toQueryComponent(element);
      if (qc != "") str += "&" + qc;
  }
  return str.substring(1);
}

function toQueryComponent(input) {
    if (!input.name || input.disabled)
        return "";

    var n = urlencode(input.name);

    switch (input.type) {
    case "text":
    case "password":
    case "submit":
    case "hidden":
        return n + "=" + urlencode(input.value);
    case "textarea":
        // normalize line breaks as CR LF pairs as per RFC 1866
        var v = input.value.split(/\r\n|\r|\n/).join("\r\n");
        return n + "=" + urlencode(v);
    case "checkbox":
    case "radio":
        if (!input.checked)
            return "";
        //var v = getRealValue(input);
        var v = input.value;
        if (v === null) v = "on";
        return n + "=" + urlencode(v);
    case "select-one":
    case "select-multiple":
        var nvp = [];
        var opt, i = 0;
        while ((opt = input.options[i++]) != null) {
            if (opt.selected) {
                var v = getRealValue(opt);
                if (v === null) v = opt.text;
                // older versions of IE do not support Array.push
                nvp[nvp.length] = n + "=" + urlencode(v);
            }
        }
        return nvp.join("&");
    default:
        // input types reset, button, image, and file not implemented
        return "";
    }
}

function urlencode(str) {
    var v;
    try { v = encodeURIComponent(str); } catch (e) { v = escape(str); }
    return v.replace(/%20/g,"+");
}

function getRealValue(input) {
    var attr = input.getAttributeNode("value");
    return (attr && attr.specified) ? input.getAttribute("value") : null;
}

function launch_js(data) {
  // RegExp from prototype.sonio.net

  data = data.replace("<!--", "");
  data = data.replace("-->", "");

  var ScriptFragment = '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)';

  var match    = new RegExp(ScriptFragment, 'img');
  var scripts  = data.match(match);

    if(scripts) {
        var js = '';
        for(var s = 0; s < scripts.length; s++) {
            var match = new RegExp(ScriptFragment, 'im');
            js += scripts[s].match(match)[1];
        }
        eval(js);
    }
}

/* end of do not change  */

var add_request;
var active_product = "";
var from_ajx = false;

function add_to_shopping_cart(product_id, qty, ajx) {

  if (active_product != "") {
    close_pop_up();
  }
	
	if(ajx == 1){
		from_ajx = true;
	}
	
  var url   = "index.php";
  var query = "cmd=add_to_shopping_cart&product_id=" + product_id + "&qty=" + qty;
  active_product = product_id;

  tmp_http_req = new init_post_request();
  add_request  = tmp_http_req.fn_request;

  add_request.onreadystatechange = show_alert;

  post_request(add_request, url, query);

}

function show_alert() {

  if (add_request.readyState == 4 || add_request.readyState == "complete") {
    data = add_request.responseText;
    var so = new SWFObject("/flash/sc.swf", "pop_up", 180, 115, "6", "#FFFFFF");
    so.addParam("wmode", "transparent");
    so.addVariable("sc_txt", data);
		if(from_ajx){
			so.write('scinfo1' + active_product);
			document.getElementById('scinfo1' + active_product).style.display = "block";
			from_ajx = false;
		}else{
    	so.write('scinfo' + active_product);
			document.getElementById('scinfo' + active_product).style.display = "block";
		}
    
    update_shopping_cart();
  }

}

function close_pop_up () {
  document.getElementById('scinfo' + active_product).style.display = "none";
  document.getElementById('scinfo' + active_product).innerHTML     = "";
	if(document.getElementById('scinfo1' + active_product)){
		document.getElementById('scinfo1' + active_product).style.display = "none";
		document.getElementById('scinfo1' + active_product).innerHTML     = "";
	}
}

var sc_request_1;
var sc_request_2;

function update_shopping_cart() {

  var url   = "index.php";
  var query = "cmd=get_total";

  tmp_http_req = new init_post_request();
  sc_request_1 = tmp_http_req.fn_request;

  sc_request_1.onreadystatechange = update_total_div;

  post_request(sc_request_1, url, query);
  
  var url   = "index.php";
  var query = "cmd=get_quantity";

  tmp_http_req = new init_post_request();
  sc_request_2 = tmp_http_req.fn_request;

  sc_request_2.onreadystatechange = update_quantity_div;

  post_request(sc_request_2, url, query);

}

function update_total_div () {
  if (sc_request_1.readyState == 4 || sc_request_1.readyState == "complete") {
    data1 = sc_request_1.responseText;
    document.getElementById('total_div').innerHTML = data1;
  }
}

function update_quantity_div () {
  if (sc_request_2.readyState == 4 || sc_request_2.readyState == "complete") {
    data2 = sc_request_2.responseText;
    document.getElementById('quantity_div').innerHTML = data2;
  }
} 

var sc_request;

function display_shopping_cart() {

  if (active_product != "") {
    close_pop_up();
  }

  var url   = "index.php";
  var query = "cmd=display_shopping_cart";
  
  tmp_http_req = new init_post_request();
  sc_request   = tmp_http_req.fn_request;

  sc_request.onreadystatechange = show_shopping_cart;

  post_request(sc_request, url, query);

}


function remove_selected_items() {

  if (active_product != "") {
    close_pop_up();
  }

  var url   = "index.php";
  var query = "cmd=remove_selected_items&" + build_query('shopping_cart_form');
  
  tmp_http_req = new init_post_request();
  sc_request   = tmp_http_req.fn_request;

  sc_request.onreadystatechange = show_shopping_cart;

  post_request(sc_request, url, query);

}

function update_quantity() {

  if (active_product != "") {
    close_pop_up();
  }

  var url   = "index.php";
  var query = "cmd=update_quantity&" + build_query('shopping_cart_form');

  tmp_http_req = new init_post_request();
  sc_request   = tmp_http_req.fn_request;

  sc_request.onreadystatechange = show_shopping_cart;

  post_request(sc_request, url, query);

}

function show_shopping_cart() {

  if (sc_request.readyState == 4 || sc_request.readyState == "complete") {
    data = sc_request.responseText;
    
    if(document.getElementById('shopping_cart_1')){
      document.getElementById('shopping_cart_1').style.display = "block";
      document.getElementById('shopping_cart_1').innerHTML = data;
    }else{
      document.getElementById('shopping_cart').innerHTML = data;
      //center_div('shopping_cart');
      document.getElementById('shopping_cart').style.display = 'block';
      x_width  = document.getElementById('shopping_cart').offsetWidth;
      x_height = document.getElementById('shopping_cart').offsetHeight;			
      document.getElementById('shopping_cart').style.display = 'none';
			document.getElementById('shopping_cart').innerHTML = "";
      
      Shadowbox.open({
        player:     'html',
        title:      'shopping cart',
        content:    data,
        height:     x_height,
        width:      x_width
      });
    } 
    update_shopping_cart();
  }

}

var validate_req;

function validate_details() {

  if (active_product != "") {
    close_pop_up();
  }

  var url   = "index.php";
  var query = "cmd=validate_details&" + build_query('customer_details');
  
  tmp_http_req = new init_post_request();
  validate_req = tmp_http_req.fn_request;

  validate_req.onreadystatechange = show_error;

  post_request(validate_req, url, query);

}

function show_error() {

  if (validate_req.readyState == 4 || validate_req.readyState == "complete") {
    data = validate_req.responseText;
    if (data == "") {
      confirm_details();
    }
    else {
      alert(data);
    }
  }

}

var confirm_req;

function confirm_details() {

  if (active_product != "") {
    close_pop_up();
  }

  var url   = "index.php";
  var query = "cmd=confirm_details&" + build_query('customer_details');
  
  tmp_http_req = new init_post_request();
  confirm_req = tmp_http_req.fn_request;

  confirm_req.onreadystatechange = display_confirmation;

  post_request(confirm_req, url, query);

}

function display_confirmation() {

  if (confirm_req.readyState == 4 || confirm_req.readyState == "complete") {
    data = confirm_req.responseText;
    document.getElementById('shopping_cart').innerHTML = data;
    center_div('shopping_cart');
  }

}

var finalise_req;

function finalise_order() {

  if (active_product != "") {
    close_pop_up();
  }

  var url   = "index.php";
  var query = "cmd=finalise_order&" + build_query('customer_details');
  
  tmp_http_req = new init_post_request();
  finalise_req = tmp_http_req.fn_request;

  finalise_req.onreadystatechange = display_paypal_page;

  post_request(finalise_req, url, query);

}

function display_paypal_page() {

  if (finalise_req.readyState == 4 || finalise_req.readyState == "complete") {
    data = finalise_req.responseText;
    document.getElementById('shopping_cart').innerHTML = data;
    center_div('shopping_cart');
    document.paypal_form.submit();
  }

}

function show_newsletter_rego() {
  document.getElementById('newsletter_rego').style.display = 'block';
}

function hide_newsletter_rego() {
  document.getElementById('newsletter_rego').style.display = 'none';
}

var subs_req;

function subscribe_to_newsletter() {

  var url   = "/ajax/newsletter_subscription.ajx.php";
  var query = "subs_email=" + document.getElementById('subs_email').value;

  tmp_http_req   = new init_post_request();
  subs_req       = tmp_http_req.fn_request;

  subs_req.onreadystatechange = update_subscription_box;

  post_request(subs_req, url, query);

}

function update_subscription_box() {

  if (subs_req.readyState == 4 || subs_req.readyState == "complete") {
    data = subs_req.responseText;
    if (data.indexOf('Thank you')) {
      alert(data);
    }
    else {
      document.getElementById('newsletter_rego').innerHTML = data;
    }
  }

}

var product_image_req;
var image_mode = "front";

function show_product_image(img) {
  
  var url   = "index.php";
  var query = "cmd=get_product_image&img=" + img;
  image_mode = "front";

  tmp_http_req      = new init_post_request();
  product_image_req = tmp_http_req.fn_request;

  product_image_req.onreadystatechange = update_product_image;

  post_request(product_image_req, url, query);

}

function update_product_image() {
  if (product_image_req.readyState == 4 || product_image_req.readyState == "complete") {
    data = product_image_req.responseText;
    document.getElementById('product_image').innerHTML = data;    
    document.getElementById('product_image').style.display = 'block';
    x_width  = document.getElementById('product_image').offsetWidth;
    x_height = document.getElementById('product_image').offsetHeight;
    document.getElementById('product_image').style.display = 'none';
		document.getElementById('product_image').innerHTML = "";
    
    Shadowbox.open({
      player:       'html',
      title:        'product details',
      content:      data,
      height:       x_height,
      width:        x_width
    });
    
    
  }
}

var back_image_req;

function swap_image (img) {
	
  if (image_mode == "front") {
    image_mode = "back";
    document.getElementById('swap_button').src = "/images/front.gif";				
  }
  else {
    image_mode = "front";
    document.getElementById('swap_button').src = "/images/back.gif";
  }
	
	
  var url   = "index.php";
  var query = "cmd=swap_image&img=" + img + "&mode=" + image_mode;

  tmp_http_req   = new init_post_request();
  back_image_req = tmp_http_req.fn_request;

  back_image_req.onreadystatechange = display_new_image;

  post_request(back_image_req, url, query);
	
}

function display_new_image() {
  if (back_image_req.readyState == 4 || back_image_req.readyState == "complete") {
    data = back_image_req.responseText;		
    document.getElementById('large_pic').innerHTML = data;
    //center_div('product_image');
  }
}

function show_gallery_image(gallery_id, pic_id, pic, pic_title, pic_width, pic_height) {

  var so = new SWFObject("/flash/gallery.swf", "gallery", "440", "255", "6", "#FFFFFF");
  so.addVariable('pic', "/downloads/Image/gallery/large/" + pic);
  so.addVariable('pic_width', pic_width);
  so.addVariable('pic_height', pic_height);
  so.addVariable('pic_title', pic_title);
  so.addParam("wmode", "transparent");
  so.write("flash_gallery_" + gallery_id);

}/*****************************************************
* ypSlideOutMenu
* 3/04/2001
*
* a nice little script to create exclusive, slide-out
* menus for ns4, ns6, mozilla, opera, ie4, ie5 on 
* mac and win32. I've got no linux or unix to test on but 
* it should(?) work... 
*
* Revised:
* - 08/29/2002 : added .hideAll()
*
* --youngpup--
*
* revised by ed for centering in browser and submenus (merged youngpup centering code and aveda submenu code)
* ed - i TRIED to comment for others to see what i did... but it is not very detailed or well commented
*****************************************************/
ypSlideOutMenu.Registry = []
ypSlideOutMenu.aniLen = 300
ypSlideOutMenu.hideDelay = 300
ypSlideOutMenu.minCPUResolution = 10

ypSlideOutMenu.styleMod = '';

function ypSlideOutMenu(id, dir, left, top, width, height, parentid, degrade, debug)
{
	this.ie = document.all ? 1 : 0
	this.ns4 = document.layers ? 1 : 0
	this.dom = document.getElementById ? 1 : 0
	
	if (this.ie || this.ns4 || this.dom) {
		this.degrade = degrade;
		this.debug = debug;
		this.sliding = false;
		this.id = id
		this.parentid = parentid
		this.dir = dir
		this.orientation = dir == "left" || dir == "right" ? "h" : "v"
		this.dirType = dir == "right" || dir == "down" ? "-" : "+"
		this.dim = this.orientation == "h" ? width : height
		this.hideTimer = false
		this.aniTimer = false
		this.open = false
		this.over = false
		this.startTime = 0
		
		// global reference to this object
		this.gRef = "ypSlideOutMenu_"+id
		eval(this.gRef+"=this")
		
		// add this menu object to an internal list of all menus
		ypSlideOutMenu.Registry[id] = this
		
		//ed - these 5 lines were in aveda but arent being used anymore.. i hope
		//this.initleft = left
		//this.inittop = top
		//this.initwidth = width
		//this.initheight = height
		//this.showcount = 0;

		var d = document
		
		//var strCSS = '<style type="text/css">';
		var strCSS = "";
		strCSS += '#' + this.id + 'Container { visibility:hidden; '
		strCSS += 'left:' + left + 'px; '
		strCSS += 'top:' + top + 'px; '
		strCSS += 'overflow:hidden; z-index:10000; }'
		strCSS += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; '
		strCSS += 'width:' + width + 'px; '
		strCSS += 'height:' + height + 'px; '
		strCSS += 'clip:rect(0 ' + width + ' ' + height + ' 0); '
		strCSS += '}'
		//strCSS += '</style>'
		//d.write(strCSS)
		this.css = strCSS;
		
		//this.load()
// The following code originally invoked "document.write" but it caused
// a crash in IE (but not NS) when there were
// more than 31 menus total.  What crashed is that the styles that were
// declared in the css disappeared with 31 menus, where 32 menus caused
// the d.write call to fail entirely.  When I changed
// it so that the style changes were accumulated into one string
// (then at the end that string was written into the document,
// so that document.write was only called once) this solved the problem.

		ypSlideOutMenu.styleMod += '#' + this.id + 'Container { visibility:hidden; ';
		ypSlideOutMenu.styleMod += 'left:' + left + 'px; ';
		ypSlideOutMenu.styleMod += 'z-index:50; ';
		ypSlideOutMenu.styleMod += 'top:' + top + 'px; ';
		ypSlideOutMenu.styleMod += 'overflow:hidden; }';
		ypSlideOutMenu.styleMod += '#' + this.id + 'Container, #' + this.id + 'Content { position:absolute; ';
		ypSlideOutMenu.styleMod += 'height:' + height + 'px; ';
		ypSlideOutMenu.styleMod += 'width:' + width + 'px; ';
		ypSlideOutMenu.styleMod += 'z-index:50; ';
		ypSlideOutMenu.styleMod += 'clip:rect(0 ' + width + ' ' + height + ' 0); ';
		ypSlideOutMenu.styleMod += '}  ';
		
		this.load()
	}
}

ypSlideOutMenu.writeCSS = function() {
	document.writeln('<style type="text/css">');

	for (var id in ypSlideOutMenu.Registry) {
		document.writeln(ypSlideOutMenu.Registry[id].css);
	}

	document.writeln('</style>');
}

ypSlideOutMenu.prototype.load = function() {
	var d = document
	var lyrId1 = this.id + "Container"
	var lyrId2 = this.id + "Content"
	var obj1 = this.dom ? d.getElementById(lyrId1) : this.ie ? d.all[lyrId1] : d.layers[lyrId1]
	if (obj1) var obj2 = this.ns4 ? obj1.layers[lyrId2] : this.ie ? d.all[lyrId2] : d.getElementById(lyrId2)
	if (!obj1 || !obj2) {
		window.setTimeout(this.gRef + ".load()", 1000);
	} else {
		this.container = obj1
		this.menu = obj2
		this.style = this.ns4 ? this.menu : this.menu.style
		// SEE NOTE ABOVE.  The following function call for the 31 menus bug.
		//this.setStyle()
		this.homePos = eval("0" + this.dirType + this.dim)
		this.outPos = 0
		this.accelConst = (this.outPos - this.homePos) / ypSlideOutMenu.aniLen / ypSlideOutMenu.aniLen 
		if (this.ns4) this.menu.captureEvents(Event.MOUSEOVER | Event.MOUSEOUT);
		this.menu.onmouseover = new Function("ypSlideOutMenu.showMenu('" + this.id + "')")
		this.menu.onmouseout = new Function("ypSlideOutMenu.hideMenu('" + this.id + "')")
		this.endSlide()
	}
}
ypSlideOutMenu.showMenu = function(id, e)
{
	var reg = ypSlideOutMenu.Registry
	var obj = ypSlideOutMenu.Registry[id]
	
	//document.getElementById('new_qq').style.display = "none";
	
	//hide_all_drop_down();
	
	if (obj.container) {
//		if (obj.ie) alert('showing: ' + id);
		obj.over = true
		if (obj.hideTimer) { reg[id].hideTimer = window.clearTimeout(reg[id].hideTimer) }
		obj.showcount++;
		if (!obj.open && !obj.aniTimer) reg[id].startSlide(true)
	}
	if (obj.ns4) obj.menu.routeEvent(Event.MOUSEOVER);
}

ypSlideOutMenu.hideMenu = function(id, e)
{
	var obj = ypSlideOutMenu.Registry[id]
	
	show_all_drop_down();
	
	if (obj.container) {
//		if (obj.ie) alert('hiding: ' + id);
		if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
		obj.showcount--;
		obj.hideTimer = window.setTimeout("ypSlideOutMenu.hide('" + id + "')", ypSlideOutMenu.hideDelay);
	}
	if (obj.ns4) obj.menu.routeEvent(Event.MOUSEOUT);
}

ypSlideOutMenu.hideAll = function()
{
var reg = ypSlideOutMenu.Registry
for (menu in reg) {
ypSlideOutMenu.hide(menu);
if (menu.hideTimer) window.clearTimeout(menu.hideTimer);
}
}

ypSlideOutMenu.hide = function(id) {
	var obj = ypSlideOutMenu.Registry[id]
	var reg = ypSlideOutMenu.Registry
	obj.over = false
	if (obj.hideTimer) window.clearTimeout(obj.hideTimer)
	obj.hideTimer = 0
	var close = true;
	for (menu in reg) {
		// for each child, if either
		//  1. the child is open or
		//  2. the child is closing (but hasn't closed yet)
		// then we don't close this menu.
		var pid = ypSlideOutMenu.Registry[menu].parentid
		if (pid == id) {
			if (ypSlideOutMenu.Registry[menu].open) close = false;
			if (!ypSlideOutMenu.Registry[menu].open && ypSlideOutMenu.Registry[menu].sliding) close = false;
		}
	}
	if (obj.open && !obj.aniTimer && close && !obj.showcount) obj.startSlide(false);
}

ypSlideOutMenu.prototype.startSlide = function(open) {
//ed - had to add this line below to make centering work
this[open ? "onactivate" : "ondeactivate"]()
	this.open = open
	if (open) this.setVisibility(true)
	this.startTime = (new Date()).getTime() 
	this.sliding = true;
	this.aniTimer = window.setInterval(this.gRef + ".slide()", ypSlideOutMenu.minCPUResolution)
}

ypSlideOutMenu.prototype.slide = function() {
	var elapsed = (new Date()).getTime() - this.startTime
	if (elapsed > ypSlideOutMenu.aniLen) this.endSlide()
	else {
		var d = Math.round(Math.pow(ypSlideOutMenu.aniLen-elapsed, 2) * this.accelConst)
		if (this.open && this.dirType == "-") d = -d
		else if (this.open && this.dirType == "+") d = -d
		else if (!this.open && this.dirType == "-") d = -this.dim + d
		else d = this.dim + d
		this.moveTo(d)
	}
}


ypSlideOutMenu.prototype.endSlide = function() {
	this.aniTimer = window.clearTimeout(this.aniTimer)
	this.moveTo(this.open ? this.outPos : this.homePos)
	if (!this.open) this.setVisibility(false)
	this.sliding = false;
	if (((this.open && !this.over) || (!this.open && this.over)) && (!this.parent || this.parent.open)) {
		this.startSlide(this.over)
	} else {
		var overchild = false;
		var reg = ypSlideOutMenu.Registry
		for (menu in reg) {
			var pid = ypSlideOutMenu.Registry[menu].parentid
			if (pid == this.id) overchild = ypSlideOutMenu.Registry[menu].over ? true : overchild		
		}
//		if (!overchild && this.parentid && !ypSlideOutMenu.Registry[this.parentid].over) ypSlideOutMenu.hideMenu(this.parentid);
		if (!overchild && this.parentid && !ypSlideOutMenu.Registry[this.parentid].over) ypSlideOutMenu.hide(this.parentid);
	}
}

ypSlideOutMenu.prototype.setVisibility = function(bShow) { 
	var s = this.ns4 ? this.container : this.container.style
	s.visibility = bShow ? "visible" : "hidden"
}

ypSlideOutMenu.prototype.moveTo = function(p) { 
// ed - without   = this.ns4 ? p : p + "px"   it gave me problems in netscape.. it wouldnt slide.
this.style[this.orientation == "h" ? "left" : "top"] = this.ns4 ? p : p + "px"
}

ypSlideOutMenu.prototype.getPos = function(c) {
	return parseInt(this.style[c])
}

//ed - had to add these 2 lines below to make centering work
ypSlideOutMenu.prototype.onactivate = function() { }
ypSlideOutMenu.prototype.ondeactivate = function() { }

function hide_all_drop_down() {

  for (i = 0; i < document.forms.length; i++) {
    var frm = document.forms[i];
    for(x=0; x< frm.length; x++){		  
      if (frm.elements[x].type == "select-one" && frm.elements[x].name != "new_pro_id") {
  		  frm.elements[x].style.visibility = "hidden"; 
      }
      if (frm.elements[x].type == "select-multiple" && frm.elements[x].name != "new_pro_id") {
        frm.elements[x].style.visibility = "hidden";
      }
    }   
  }

}

function show_all_drop_down () {

  for (i = 0; i < document.forms.length; i++) {
    var frm = document.forms[i];
    for(x=0; x< frm.length; x++){
      if (frm.elements[x].type == "select-one") {
			  /*
			  if (!qq_interface_on) {
				  frm.elements[x].style.visibility = "visible"; 
				} 
				*/        
	    }
      if (frm.elements[x].type == "select-multiple") {
			  /*
			  if (!qq_interface_on) {
          frm.elements[x].style.visibility = "visible";
				}
				*/
      }
    }   
  }

}/*
 ## Author: Abhishek V.P
 ## Class : Google map builder
*/

var abmap=null
 var geocoder = null;
 var marker;
var classObject;
	 var myPano;
	 var glatlng;
	 var panoClient;
	 var closeevnt=false;
	 var panoRemoved=false;
	 var setStreetMap=false;
	 var setStreetMapId='pann';
	 var setAddress='';
	 var hybridMap=true;
function GmapClass()
{	
/*
 ## Author: Abhishek V.P
 ## Class : Google map builder
*/

this.loadGmap= loadGmap;
this.setMapType=setMapType;
this.setCenter=setCenter;
this.setStreetFlash=setStreetFlash;
this.createdummyElement=createdummyElement;
this.enableScroll=true;
this.setStreetMap=setStreetMap;
this.setStreetMapId=setStreetMapId;
this.setAddress=setAddress;
this.hybridMap=hybridMap;

this.lat=-37.848676;
this.lng=145.079256;

this.mapcontrol=new GSmallMapControl();
this.markerText="Marker window Text, you can modify the object.markerText property";


function setCenter()
{
  this.center=new GLatLng(this.lat, this.lng);
}

function setMapType(type)
{
 if(type=='big')
 {
   this.mapcontrol=new GLargeMapControl();

 }
 else
 {
   this.mapcontrol=new GSmallMapControl();
 }
}

	function wheelevent(e)
	{
	 if (!e) {  e = window.event } if (e.preventDefault) {  e.preventDefault() } e.returnValue = false;
	}	
	function createdummyElement()
	{
	 if(document.getElementById('examap'))
	 {
	 var elem=document.createElement('<div>');
		  elem.id='pano';
		  elem.innerHTML='test';
		  elem.style.display='none';
		  elem.style.width='600px';
		  elem.style.height='300px';		  
		  document.body.appendChild(elem);
	 }
	 else
	 {
	  setTimeout('classObject.createdummyElement()',1000);
	 }
	}

	function loadGmap() { 
	var localObject=this;
	      if (GBrowserIsCompatible()) {
		  
            abmap = new GMap2(document.getElementById("examap"));
			panoClient = new GStreetviewClient();
		    geocoder = new GClientGeocoder();
			if(this.enableScroll)
			{
		     abmap.enableScrollWheelZoom();
			} 
			abmap.addControl(this.mapcontrol);
			abmap.addControl(new GMapTypeControl());
			
			 if(this.setAddress!='')       
			{		
			        
					geocoder.getLatLng(localObject.setAddress, function(point) { 
					if (point) {
					
					 localObject.center=point ;
					 abmap.setCenter(localObject.center, 17);
					   var marker = new GMarker(point);
			           abmap.addOverlay(marker);
					abmap.setMapType(G_HYBRID_MAP);
					 marker.openInfoWindowHtml(localObject.markerText);
					 GEvent.addListener(marker, "click", function() {
	                marker.openInfoWindowHtml(localObject.markerText);				
			  });  
					 
					}
					else{
					// alert(this.setAddress + " not found");
					 }
					 }   );
            }  		
           else
		   {		
 			this.center=new GLatLng(this.lat, this.lng);
			abmap.setCenter(this.center, 17);
			additions(abmap,this)
		    }
      }
    } 


function additions(abmap,object)
{
if(object.hybridMap)
{
	abmap.setMapType(G_HYBRID_MAP);
}			
		 
		    marker = new GMarker(object.center, {draggable:false});
		    abmap.addOverlay(marker);
		    
			if(object.setStreetMap && document.getElementById(object.setStreetMapId))
			{
			 svOverlay = new GStreetviewOverlay();
			 abmap.addOverlay(svOverlay);
		    } 
				GEvent.addListener(marker, "click", function() {
	                marker.openInfoWindowHtml(object.markerText);				
			  });  
			  
	
			
			
		   if(object.setStreetMap && document.getElementById(object.setStreetMapId))
			{
				 GEvent.addListener(abmap,"click", function(overlay,latlng) {
				 glatlng=latlng;
				 setStreetFlash();
				 }); 
			}
			
		 
			  marker.openInfoWindowHtml(object.markerText);
}

	
    function setStreetFlash()
	{
			
	if(document.getElementById(this.setStreetMapId))
	{
		
				if(glatlng!=undefined)
				{
					
					try
						  {
							myPano = new GStreetviewPanorama(document.getElementById(this.setStreetMapId));  
							myPano.setLocationAndPOV(glatlng);
						  }
						catch(err)
						  {
						  txt="There was an error on this page.\n\n"
						  txt+="Error description: " + err.description + "\n\n"
						  txt+="Click OK to continue.\n\n"
						 // alert(txt)
						  }
					
				}
				
				
	}
	else
	{
  
	   setTimeout('classObject.setStreetFlash()',1000);
	
	} 

	}
	 classObject=this;
}	var browser, verStr = navigator.appVersion, app = navigator.appName, version = parseFloat(verStr);

function test_browser() {
  if ((app.indexOf('Netscape') != -1) && version >= 5) {
    browser = "netscape";
  }
  else if ((app.indexOf('Microsoft') != -1) && version >= 4) {
    browser = "ie";
  }
}

var body_content = new Array("bodycontent", "preloader");
test_browser();
function show_sub(show_which_sub, var_array, mode) {

  if (mode == "preloader") {
    for (i = 0; i < eval(var_array + ".length"); i++) {
      if (eval(var_array + "[i]") != show_which_sub) {
        hide_sub(eval(var_array + "[i]"), mode);
      }
    }
  }

  if (show_which_sub != "") {
    if (browser == "netscape") {
      if (document.getElementById(show_which_sub).style.display == 'block') {
        document.getElementById(show_which_sub).style.display = 'none';
      }
      else {
        document.getElementById(show_which_sub).style.display = 'block';
      }
    }
    else if (browser == "ie") {
      show_menu = eval(show_which_sub);
      if(show_menu.style.display == 'block'){
        show_menu.style.display = 'none';
      }
      else {
        show_menu.style.display = 'block';
      }
    }
  }

}

function hide_sub(which_sub, mode) {
  if (browser == "netscape") {
    document.getElementById(which_sub).style.display = 'none';
  }
  else if (browser == "ie") {
    sub_menu = eval(which_sub);
    sub_menu.style.display = 'none';
  }
}

function auto_hide() {
  show_sub("");
}

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];}}
}

function MM_findObj(n, d) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); 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 scroll_up() {
  current_pos = document.getElementById('scroll_clipper').scrollTop;
  document.getElementById('scroll_clipper').scrollTop = current_pos + 20;
}

function scroll_down() {
  current_pos = document.getElementById('scroll_clipper').scrollTop;
  document.getElementById('scroll_clipper').scrollTop = current_pos - 20;
}

function char_count(eid, maxlen, max_lines) {

  var inputstr;
  var strlen;
  var charleft;
  var numcr;
  var temp = new Array();

  if (document.getElementById(eid).value != "") {
    inputstr = document.getElementById(eid).value;
    strlen = inputstr.length;

    if (strlen > maxlen) {
      document.getElementById(eid).value = document.getElementById(eid).value.substring(0,maxlen);
      charleft = 0;
      alert("Exceeds maximum number of characters!");
    }
    else {
      charleft = maxlen - strlen;
    }

    document.getElementById('charleft' + eid).innerHTML = charleft + " / " + maxlen;

  }

  if (max_lines > 0) {

    var temp2 = document.getElementById(eid).value.split('\r\n');
    var temp_val = "";
    counter = 0;
    if (temp2.length > max_lines) {
      alert("Exceeds maximum number of lines!");
      for (i = 0; i < max_lines; i++) {
        temp_val = temp_val + temp2[i];
        if (i < (max_lines - 1)) {
          temp_val = temp_val + "\n";
        }
      }
      document.getElementById(eid).value = temp_val;
    }

  }

}

function row_over(row_id, row_color) {
  document.getElementById(row_id).style.backgroundColor = row_color;
}

function add_to_favorite(url, title) {
  if (window.sidebar) {
    window.sidebar.addPanel(title, url, "");
  }
  else if( window.external ) {
    window.external.AddFavorite(url, title);
  }
  else if (window.opera && window.print) {
    return true;
  }
}

function mdiv(menu_id) {

  ffile = "flash/mdiv.swf";
  mn_name = "MM" + menu_id;
  document.write("<span id='" + mn_name + "'></span>");

  var fmn = new SWFObject(ffile, "mn", "282", "5", "5", "#FFFFFF");
  fmn.addParam("wmode", "transparent");
  fmn.write(mn_name);

}

function mm(page_title, menu_id, level, page, submenu, quick_link) {

  ffile = "flash/m" + level + ".swf";
  mn_name = "MM" + menu_id;
  document.write("<span id='" + mn_name + "'></span>");

  var fmn = new SWFObject(ffile, "mn", "282", "35", "6", "#FFFFFF");
  fmn.addVariable("page_id",    menu_id);
  fmn.addVariable("page",       page);
  fmn.addVariable("page_title", page_title);
  fmn.addVariable("submenu",     submenu);
  fmn.addVariable("quick_link",     quick_link);
  fmn.addParam("wmode", "transparent");
  fmn.write(mn_name);

}

var w_width = w_height = 0;

function get_window_size() {
  if (parseInt(navigator.appVersion)>3) {
    if (navigator.appName=="Netscape") {
      w_width = window.innerWidth;
      w_height = window.innerHeight;
    }
    if (navigator.appName.indexOf("Microsoft")!=-1) {
      w_width = document.body.offsetWidth;
      w_height = document.body.offsetHeight;
    }
  }
}

active_image = "";

function show_image(img_id, pic, pic_width, pic_height) {

  //get_window_size();

  hide_image();

  var so = new SWFObject("flash/pop.swf", "pop_up", 330, 255, "6", "#FFFFFF");
  so.addParam("wmode", "transparent");
  so.addVariable("pic", pic);
  so.addVariable("pic_width", pic_width);
  so.addVariable("pic_height", pic_height);
  so.write('big_pic');

  document.getElementById(img_id).style.display = "block";

  active_image = img_id;

}

function hide_image() {

  if (document.getElementById(active_image)) {
    document.getElementById(active_image).style.display = "none";
  }

}

function youtube(youtube_code) {

  url = "youtube_viewer.php?youtube=" + youtube_code;
  window.open(url,'browser','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=445,height=375')

}

var min = 8;
var max = 16;

function font_up() {

   var p = document.getElementsByTagName('body');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}

function font_down() {

   var p = document.getElementsByTagName('body');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 12;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }

}

function CreateBookmarkLink(title, url) {

  if (window.sidebar) { // Mozilla Firefox Bookmark
    window.sidebar.addPanel(title, url,"");
  }
  else if( window.external ) { // IE Favorite
    window.external.AddFavorite( url, title); }
    else if(window.opera && window.print) { // Opera Hotlist
      return true;
    }
  }

  if (window.external) {
    //document.write('<a href =\"javascript:CreateBookmarkLink()\");">Add to Favorites</a>');
  }
  else  if (window.sidebar) {
    //document.write('<a href =\"javascript:CreateBookmarkLink()\");">Bookmark Page</a>');
  }
  else if (window.opera && window.print) {
    //document.write('<a href =\"javascript:CreateBookmarkLink()\");">Add Bookmark</a>');
}

function show_subscription_box() {
  document.getElementById('newsletter_subscription_box_1').style.display='block'
  document.getElementById('subs_name').focus();
}

var active_faq = "";

function show_faq (eid) {

  if (active_faq != "") {
    document.getElementById(active_faq).style.display = "none";
  }
  document.getElementById(eid).style.display = "block";
  active_faq = eid;

}

function refresh_calendar() {
  cyear  = document.getElementById('cyear').value;
  cmonth = document.getElementById('cmonth').value;
  window.location = "index.php?year=" + cyear + "&month=" + cmonth;
}

var event_req = "";

function get_event(date) {

  var query = "&date=" + date;
  var url   = "ajax/events.ajx.php";

  document.getElementById('selected_event').innerHTML = "Loading event...";

  tmp_http_req   = new init_post_request();
  event_req      = tmp_http_req.fn_request;

  event_req.onreadystatechange = show_event;

  post_request(event_req, url, query);

  return;

}

function show_event() {

  if (event_req.readyState == 4 || event_req.readyState == "complete") {
    data = event_req.responseText;
    document.getElementById('selected_event').innerHTML = data;
  }

}

var active_answer = "";

function show_answer(eid) {

  if (active_answer != "") {
    document.getElementById(active_answer).style.display = "none";
  }
  document.getElementById(eid).style.display = "block";
  active_answer = eid;

}

function update_team_details() {

  if (document.getElementById('team_name').value != "") {
    document.getElementById('new_team_details').style.display = "block";
  }
  else {
    document.getElementById('new_team_details').style.display = "none";
  }
  document.getElementById('new_team_name').value = document.getElementById('team_name').value;

}

function disable_rego_buttons() {
  var buttons = new Array("reset", "cmd", "cmd1", "cmd2", "cmd3");
  for (i = 0; i <= buttons.length; i++) {
    if (document.getElementById(buttons[i])) {
      document.getElementById(buttons[i]).disabled = true;
    }
  }
}

function alert_elite() {

  if (document.getElementById('category').value == 0 && document.getElementById('category').value != "") {
    alert("Qualifying time required: \n- Male: < 4:15\n- Female: < 4:45");
  }

}

function select_category (current) {

  dob_year = document.getElementById('dob_year').value;

  if (current - dob_year <= 14) {
    document.getElementById('category').value = 1;
  }
  else if (current - dob_year <= 17) {
    document.getElementById('category').value = 2;
  }
  else if (current - dob_year <= 34) {
    document.getElementById('category').value = 3;
  }
  else if (current - dob_year <= 49) {
    document.getElementById('category').value = 4;
  }
  else {
    document.getElementById('category').value = 5;
  }

}

function check_source() {
  document.getElementById('other_source').style.display = "none";
  if (document.getElementById('source').value == "Other") {
    document.getElementById('other_source').style.display = "block";
  }
}

function check_billing_address() {
  var fields = new Array("address_1", "address_2", "city", "state", "zip");
  if (document.getElementById('billing_address').value == "same") {
    for (i = 0; i < fields.length; i++) {
      document.getElementById('bill_' + fields[i]).value = document.getElementById(fields[i]).value;
    }
  }
}

function getViewportHeight() {
  if (window.innerHeight!=window.undefined) return window.innerHeight;
  if (document.compatMode=='CSS1Compat') return document.documentElement.clientHeight;
  if (document.body) return document.body.clientHeight;

  return window.undefined;
}

function getViewportWidth() {
  var offset = 16;
  var width = null;
  if (window.innerWidth!=window.undefined) return window.innerWidth + offset;
  if (document.compatMode=='CSS1Compat') return document.documentElement.clientWidth + offset;
  if (document.body) return document.body.clientWidth + offset;
}

function getScrollTop() {
  if (self.pageYOffset) // all except Explorer
  {
    return self.pageYOffset;
  }
  else if (document.documentElement && document.documentElement.scrollTop)
    // Explorer 6 Strict
  {
    return document.documentElement.scrollTop;
  }
  else if (document.body) // all other Explorers
  {
    return document.body.scrollTop;
  }
}

function getScrollLeft() {
  if (self.pageXOffset) // all except Explorer
  {
    return self.pageXOffset;
  }
  else if (document.documentElement && document.documentElement.scrollLeft)
    // Explorer 6 Strict
  {
    return document.documentElement.scrollLeft;
  }
  else if (document.body) // all other Explorers
  {
    return document.body.scrollLeft;
  }
}

var actively_displayed_div = "";

function center_div(which_div) {

  actively_displayed_div = which_div;
  document.getElementById(which_div).style.display = "block";

  newWidth  = document.getElementById(which_div).offsetWidth;
  newHeight = document.getElementById(which_div).offsetHeight;

  var theBody = document.getElementsByTagName("body")[0];
  var scTop = parseInt(getScrollTop(),10);
  var scLeft = parseInt(theBody.scrollLeft,10);
  var fullHeight = getViewportHeight();
  var fullWidth = getViewportWidth();
  var sc_left = getScrollLeft();

  document.getElementById(which_div).style.top     = (scTop + ((fullHeight - newHeight) / 2)) + "px";
  document.getElementById(which_div).style.left    = (scLeft + sc_left + ((fullWidth - newWidth) / 2)) + "px";

}

function re_center_div () {
  if (actively_displayed_div != "" && document.getElementById(actively_displayed_div).style.display == "block") {
    center_div(actively_displayed_div);
  }
}

function addevent(obj,evt,fn,capt){
  if(obj.addEventListener) {
    obj.addEventListener(evt, fn, capt);
    return true;
  }
  else if(obj.attachEvent) {
    obj.attachEvent('on'+evt, fn);
    return true;
  }
  else return false;
}

if (document.getElementById && document.getElementsByTagName) {
  addevent(window, 'load', re_center_div, false);
  addevent(window, 'resize', re_center_div, false);
  addevent(window, 'scroll', re_center_div, false);
}

function open_in_shadowbox (source, type, title) {
  Shadowbox.open({
    player:     type,
    title:      title,
    content:    source
  });
}

Shadowbox.loadSkin('classic', '/javascripts/skin');
Shadowbox.loadLanguage('en', '/javascripts/lang');
Shadowbox.loadPlayer(['flv', 'html', 'iframe', 'img', 'qt', 'swf', 'wmp'], '/javascripts/player');

function sb_init() {
  Shadowbox.init({
    // let's skip the automatic setup because we don't have any
    // properly configured link elements on the page
    skipSetup: true
   });
}
var active_menu ="";
function show_submenu(menuid)
{
  if(active_menu !="" && active_menu != menuid){
    document.getElementById(active_menu).style.display = "none";
  }
    document.getElementById(menuid).style.display = "block";
    active_menu = menuid;
}

function load_video (video_url) {
  Shadowbox.open({
    player:     'iframe',
    content:    video_url,
    height:     '580',
    width:      '780',
    overlayColor:    "#FFF"
  });
}

function setImgSrc(id,src){
	$('#'+id).attr('src',"/images/"+src);
}

// jquery pagination
$(document).ready(function(){
	
	//how much items per page to show
	var show_per_page = 3; 
	//getting the amount of elements inside content div
	var number_of_items = $('#p_container').children('.p_row').size();
	//calculate the number of pages we are going to have
	var number_of_pages = Math.ceil(number_of_items/show_per_page);
	
	//set the value of our hidden input fields
	$('#current_page').val(0);
	$('#show_per_page').val(show_per_page);
	
	//now when we got all we need for the navigation let's make it '
	
	/* 
	what are we going to have in the navigation?
		- link to previous page
		- links to specific pages
		- link to next page
	*/
	var navigation_html = '<a class="previous_link" href="javascript:previous();">Prev</a>';
	var current_link = 0;
	while(number_of_pages > current_link){
		navigation_html += '<a class="page_link" href="javascript:go_to_page(' + current_link +')" longdesc="' + current_link +'">'+ (current_link + 1) +'</a>';
		current_link++;
	}
	navigation_html += '<a class="next_link" href="javascript:next();">Next</a>';
	
	$('#page_navigation').html(navigation_html);
	
	//add active_page class to the first page link
	$('#page_navigation .page_link:first').addClass('active_page');
	
	//hide all the elements inside content div
	$('#p_container').children('.p_row').css('display', 'none');
	
	//and show the first n (show_per_page) elements
	$('#p_container').children('.p_row').slice(0, show_per_page).css('display', 'block');
	
});
$(document).ready(function(){
	
	//how much items per page to show
	var show_per_page2 = 2; 
	//getting the amount of elements inside content div
	var number_of_items = $('#pvid_container').children('.p_row').size();
	//calculate the number of pages we are going to have
	var number_of_pages = Math.ceil(number_of_items/show_per_page2);
	
	//set the value of our hidden input fields
	$('#current_page').val(0);
	$('#show_per_page2').val(show_per_page2);
	
	//now when we got all we need for the navigation let's make it '
	
	/* 
	what are we going to have in the navigation?
		- link to previous page
		- links to specific pages
		- link to next page
	*/
	var navigation_html = '<a class="previous_link" href="javascript:previous2();">Prev</a>';
	var current_link = 0;
	while(number_of_pages > current_link){
		navigation_html += '<a class="page_link" href="javascript:go_to_page2(' + current_link +')" longdesc="' + current_link +'">'+ (current_link + 1) +'</a>';
		current_link++;
	}
	navigation_html += '<a class="next_link" href="javascript:next2();">Next</a>';
	
	$('#page_navigation2').html(navigation_html);
	
	//add active_page class to the first page link
	$('#page_navigation2 .page_link:first').addClass('active_page');
	
	//hide all the elements inside content div
	$('#pvid_container').children('.p_row').css('display', 'none');
	
	//and show the first n (show_per_page) elements
	$('#pvid_container').children('.p_row').slice(0, show_per_page2).css('display', 'block');
	
});

function previous(){
	
	new_page = parseInt($('#current_page').val()) - 1;
	//if there is an item before the current active link run the function
	if($('.active_page').prev('.page_link').length==true){
		go_to_page(new_page);
	}
	
}

function next(){
	new_page = parseInt($('#current_page').val()) + 1;
	//if there is an item after the current active link run the function
	if($('.active_page').next('.page_link').length==true){
		go_to_page(new_page);
	}
	
}
function go_to_page(page_num){
	//get the number of items shown per page
	var show_per_page = parseInt($('#show_per_page').val());
	
	//get the element number where to start the slice from
	start_from = page_num * show_per_page;
	
	//get the element number where to end the slice
	end_on = start_from + show_per_page;
	
	//hide all children elements of content div, get specific items and show them
	$('#p_container').children('.p_row').css('display', 'none').slice(start_from, end_on).css('display', 'block');
	
	/*get the page link that has longdesc attribute of the current page and add active_page class to it
	and remove that class from previously active page link*/
	$('.page_link[longdesc=' + page_num +']').addClass('active_page').siblings('.active_page').removeClass('active_page');
	//update the current page input field
	$('#current_page').val(page_num);
          $.ajax({url:"/script.php", 
                  type: "POST",
                  data :'page_num='+page_num ,
             success:function(data_page){
                //alert(data_page);
             }
          });


}
function previous2(){
	new_page = parseInt($('#current_page').val()) - 1;
	//if there is an item before the current active link run the function
	if($('.active_page').prev('.page_link').length==true){
		go_to_page2(new_page);
	}
}
function next2(){
	new_page = parseInt($('#current_page').val()) + 1;
	//if there is an item after the current active link run the function
	if($('.active_page').next('.page_link').length==true){
		go_to_page2(new_page);
	}
}
function go_to_page2(vpage_num){

	//get the number of items shown per page
	var show_per_page2 = parseInt($('#show_per_page2').val());
	
	//get the element number where to start the slice from
	start_from = vpage_num * show_per_page2;
	
	//get the element number where to end the slice
	end_on = start_from + show_per_page2;
	
	//hide all children elements of content div, get specific items and show them
	$('#pvid_container').children('.p_row').css('display', 'none').slice(start_from, end_on).css('display', 'block');
	
	/*get the page link that has longdesc attribute of the current page and add active_page class to it
	and remove that class from previously active page link*/
	$('.page_link[longdesc=' + vpage_num +']').addClass('active_page').siblings('.active_page').removeClass('active_page');
	
	//update the current page input field
	$('#current_page').val(vpage_num);
        $('#current_page').val(vpage_num);
        $.ajax({url:"/script_video.php",
                type: "POST",
                data :'vpage_num='+vpage_num ,
             success:function(data_page){
                //alert(data_page);
             }
          });
}
// end jquery pagination
