// Function to get Element by Id
function $() {
  var elements = new Array();
  for (var i = 0; i < arguments.length; i++) {
    var element = arguments[i];
    if (typeof element == 'string')
      element = document.getElementById(element);
    if (arguments.length == 1)
      return element;
    elements.push(element);
  }
  return elements;
} 

/***********************************
 * Class for storing browser information, preloadImages, etc
 * 
 **********************************/
function dhtml(){
	//Browser Information
	this.User_agent = navigator.userAgent.toLowerCase();
	this.version    = this.User_agent;
	this.Opera    	= ( window.opera );
	this.IE       	= ( ( this.User_agent.indexOf("msie") != -1 ) && ( !this.Opera ) );
	this.MAC      	= ( this.User_agent.indexOf("mac") != -1 );
	this.Gecko    	= ( navigator.product == "Gecko" );
	this.Mozilla  	= this.Gecko;
	
	if (this.IE){
		//mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; sv1; .net clr 1.1.4322)
		pos = this.User_agent.indexOf('msie')+5;
		this.version = this.User_agent.substring(pos,pos+3)
	} else if (this.Opera) {
		//mozilla/4.0 (compatible; msie 6.0; windows nt 5.1; en) opera 8.0
		pos = this.User_agent.indexOf('opera')+6;
		this.version = this.User_agent.substring(pos,pos+3)
	} else if (this.Gecko) {
		//mozilla/5.0 (windows; u; windows nt 5.1; ru-ru; rv:1.7.12) gecko/20050919 firefox/1.0.7
		pos = this.User_agent.indexOf('gecko')+6;
		this.version = this.User_agent.substring(pos,pos+8)
	} else if (this.MAC) {
		pos = this.User_agent.indexOf('safari')+7;
		this.version = this.User_agent.substring(pos,pos+3)
	}

	//Image Preloader
	this.preloadImages = function(){
		var d = document;
		if(d.images){
			if(!d.pics)
				d.pics = new Array();
			var i,j = d.pics.length, a = this.preloadImages.arguments;
			for(i = 0; i < a.length; i++)
				if (a[i].indexOf("#")!=0){ 
					d.pics[j]=new Image; d.pics[j++].src=a[i]
				}
		} 
	}  
}
var dhtml = new dhtml();
/***********************************
 * Class for working with Cookie
 * 
 * Example 1: 
   ---------
	Cookie.set('sampleVar', 'HelloWorld!', null, '/');
	Cookie.get('sampleVar');
	Cookie.del('sampleVar', '/');
	Cookie.delAll();
 **********************************/
(Cookie = {
  hash : [], // hash of cookies
  init : function () {
    if (""!=document.cookie) {
      var p = document.cookie.split(/\s*;\s*/);
      for (i=0;i<p.length;i++) {
        var parts = p[i].split(/\s*=\s*/);
        Cookie.hash[parts[0]] = parts[1]?unescape(parts[1]):"";
      }
    }
  },
  get : function (name) {
    return Cookie.hash[name]?Cookie.hash[name]:false;
  },
  set : function (name, value, expire, path, domain, secure) {
    if (""!=name) {
      document.cookie = name + "=" + escape(value) +
      ((path == null) ? "" : ";path=" + path) +
      ((expire == null) ? "" : ";NoExp=" + ((typeof(expire)=='object')?expire.toGMTString():new Date(new Date().getTime()+expire*1000).toGMTString())) +
      ((domain == null) ? "" : ";domain=" + domain) +
      ((secure == null) ? "" : ";secure");
      Cookie.hash[name] = escape(value);
      return true;
    }
    return false;
  },
  isSet : function (name) {
    return Cookie.hash[name]?true:false;
  },
  del : function (name,path,domain) {
    if (Cookie.isSet(name)) {
      document.cookie = name + "=" +
      ((path == null) ? "" : "; path=" + path) +
      ((domain == null) ? "" : "; domain=" + domain) +
      "; NoExp=Thu, 01-Jan-70 00:00:01 GMT";
      delete Cookie.hash[name];
      return true;
    }
    return false;
  },
  delAll : function () {
    var i;
    for (i in Cookie.hash) {
      Cookie.del(i);
    }
    return true;
  }
}).init();

/***********************************
 * Class for working with flash
 * 
 * Example 1: 
   ---------
   oFlash = new Flash(); // creating of flash object
   var sNoFlash = "Update your flash version";
   oFlash.build( "source=sample.swf,width=100,height=100,bgcolor=#ffffff,transparent=true", "", sNoFlash, 8, flashVariables);
 * Ecample 2:
   ---------
   oFlash = new Flash(); // creating of flash object
   var sNoFlash = "Update your flash version";
   oFlash.build( document.getElementById('sampleToShowFlashId'), document.getElementById('sampleToHideFlashId'), sNoFlash, 8);

 **********************************/
function Flash(){
	var aeFlash = new Array();

	this.build = function( vEnabled, vDisabled, vNone, iVersion, flashVariables ){
		flashVariables = (flashVariables)?(flashVariables):('');
		var vVersion = this.get_version( iVersion );
		if( vVersion.toString() != "false" ){
			this.enable();
			vVersion = this.get_version( iVersion );
		}
		if( vVersion ){
			if( vEnabled.nodeType )	vEnabled.style.display = "block";
			else return build_object(vEnabled, flashVariables, vVersion);
			if( vDisabled.nodeType ) vDisabled.style.display = "none";
			if( vNone.nodeType ) vNone.style.display = "none";
		}else{
			if( vEnabled.nodeType ) vEnabled.style.display = "none";
			if( vDisabled.nodeType ) vDisabled.style.display = "block";
			else if( vDisabled ) return vDisabled;
			if( parseInt(vVersion) == 0 );
				if( vNone.nodeType ) vNone.style.display = "block";
				else if( vNone ) return vNone;
		}
	}
	
	this.get_version = function( iVersion ){
		var vVersion = Cookie.get("flash");
		if( !vVersion ){
			vVersion = check_flash_version( iVersion );
			Cookie.set("flash",( vVersion ) ? vVersion : "", 1000 * 60);
			return vVersion;
		}else if( iVersion && iVersion > vVersion ){
			vVersion = false;
		}
		return ( vVersion == "false" ) ?  false : vVersion;
	}
	
	this.disable = function(){
		set_flash_disabled( true );
	}
	
	this.enable = function(){
		set_flash_disabled( false );
	}
	
	this.set_disabled = function( bDisabled ){
		set_flash_disabled( bDisabled );
	}

	return this;

	function build_object( sOptions, sFlashVariables, vVersion ){
		sFlashVariables = (sFlashVariables)?(sFlashVariables):(null);
		var asOptions = sOptions.split( "," );
		for( var i = 0 ; i < asOptions.length ; i++){
			asPair = asOptions[i].split( "=" );
			asOptions[asPair[0]] = unescape(asPair[1]);
		}
		var sHTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
		sHTML += 'codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+vVersion+',0,0,0" width="' + asOptions.width + '" height="' + asOptions.height + '" align="middle">' + '<param name="allowScriptAccess" value="sameDomain">' + '<param name="movie" value="' + asOptions.source + '">' + '<param name="quality" value="high">';
		if( asOptions.background ){ sHTML += '<param name="bgcolor" value="' + asOptions.background + '">'; }
		if( asOptions.transparent ){ sHTML += '<param name="wmode" value="transparent">' }
		if( sFlashVariables ){ sHTML += '<param name="flashvars" value="' + sFlashVariables + '">'; }
		sHTML += '<embed quality="high" allowScriptAccess="sameDomain" type="application/x-shockwave-flash"' + ' pluginspage="http://www.macromedia.com/go/getflashplayer"' + ' src="' + asOptions.source + '" width="' + asOptions.width + '" height="' + asOptions.height + '"';
		if( asOptions.background ){ sHTML += ' bgcolor="' + asOptions.background + '"'; }
		if( asOptions.transparent ){ sHTML += ' wmode="transparent"' }
		if( sFlashVariables ){ sHTML += ' flashvars="' + sFlashVariables + '"'; }
		sHTML += '></embed></object>';
		return sHTML;
	}
	
	function set_flash_disabled( bDisabled ){
		Cookie.set("flash",( bDisabled ) ?  "false" : "", 1000 * 60);
	}
	
	function check_flash_version( iVersion ){
		if( navigator.plugins && navigator.plugins['Shockwave Flash'] ){
			var sVersion = ( !iVersion ) ? "\\d+" : "[" + iVersion + "-9]\\d*";
			sVersion = parseInt( navigator.plugins['Shockwave Flash'].description.replace( new RegExp( "^[^\\d]+(" + sVersion + ").*$"), "$1" ) );
			return ( isNaN( sVersion ) ) ? ( !iVersion ) ? false : 0 : sVersion;
		}else if( dhtml.IE && !dhtml.MAC ){
			var oTemp, iMax = 20;
			iVersion = ( !iVersion ) ? 3 : iVersion;
			for( var i = iVersion ; i < iMax ; i++ ){
				try{
					oTemp = new ActiveXObject( "ShockwaveFlash.ShockwaveFlash." + i );
					iVersion = i;
				}catch(e){
					return ( i > iVersion ) ? iVersion : 0;
				}
			}
			return iVersion;
		}else{
			return ( !iVersion ) ? false : 0;
		}
	}
}

function ShowHideFileds() {
rowsToHide=6;
RowToGo=Starter;
for (var i=1;i<=rowsToHide;i++) {
	RowToGo.style.display=(ShowStatus)?'block':'none';
	RowToGo=RowToGo.nextSibling;
	}
}
