// JavaScript Document

function open_popup(url,popup_name,width,height,left,top){
	window.open(url,popup_name, 'height='+height+', width='+width+', left='+left+',top='+top+',toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no');
}

function openEventpage(day, month, year) {
	location.href = '?mod=home&act=event&day='+day+'&month='+month+'&year='+year;
}
function doSaveLottery(){
	var frm = document.frmAddLottery.submit();
}
function validateEmail(email) {
	var re_mail = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z])+$/;
	if (!re_mail.test(email.value)) {
		return false;
	}
	return true;
}
function checkNumber(number){
	var oldstring = number.value; 
	var newstring = parseFloat(oldstring).toString(); 
	var InpValid=1; 
	if (oldstring.length != newstring.length || newstring == "NaN") { 
		InpValid=0; 
		return false;
	} 
	return true;
}
// sort function - ascending (case-insensitive)
function sortFuncAsc(record1, record2) {
	var value1 = record1.optText.toLowerCase();
	var value2 = record2.optText.toLowerCase();
	if (value1 > value2) return(1);
	if (value1 < value2) return(-1);
	return(0);
}

// sort function - descending (case-insensitive)
function sortFuncDesc(record1, record2) {
	var value1 = record1.optText.toLowerCase();
	var value2 = record2.optText.toLowerCase();
	if (value1 > value2) return(-1);
	if (value1 < value2) return(1);
	return(0);
}

function sortSelect(selectToSort, ascendingOrder) {
	if (arguments.length == 1) ascendingOrder = true;    // default to ascending sort

	// copy options into an array
	var myOptions = [];
	for (var loop=0; loop<selectToSort.options.length; loop++) {
		myOptions[loop] = { optText:selectToSort.options[loop].text, optValue:selectToSort.options[loop].value };
	}

	// sort array
	if (ascendingOrder) {
		myOptions.sort(sortFuncAsc);
	} else {
		myOptions.sort(sortFuncDesc);
	}

	// copy sorted options from array back to select box
	selectToSort.options.length = 0;
	for (var loop=0; loop<myOptions.length; loop++) {
		var optObj = document.createElement('option');
		optObj.text = myOptions[loop].optText;
		optObj.value = myOptions[loop].optValue;
		selectToSort.options.add(optObj);
	}
}
//-- Check validate
function check_empty(object,txtAlert){
	if(object.value == ''){
		alert("Please input "+txtAlert+"!");
		object.focus();
		return false;
	}
	return true;
}
//contact us
function doSubmit_contact(){
	var frm = document.frmReg;
			if(check_empty(frm.bc_firstname,'bc_firstname'))
				if(check_empty(frm.bc_lastname,'bc_lastname'))
					if(check_empty(frm.bc_address,'bc_address'))
						if(check_empty(frm.bc_phone,'bc_phone'))
							if(check_empty(frm.bc_comment,'bc_comment'))						
							{
								if(validateEmail(frm.bc_email) == false){
									alert("Invalid email address!");
									frm.bc_email.focus();
									return false;
								}
								frm.submit();
							}
}
// Register
function doSubmit(){
	var frm = document.frmReg;
	if(check_empty(frm.user_name,'user name'))
		if(check_empty(frm.password,'password'))			
			if(check_empty(frm.first_name,'first name'))
				if(check_empty(frm.last_name,'last name'))
					if(check_empty(frm.email,'email'))
						if(check_empty(frm.ts_code,'captcha')){
							if(frm.password.value != frm.c_password.value){
								alert("Please confirm the password!");
								frm.c_password.focus();
								return false;
							}
							if(validateEmail(frm.email) == false){
								alert("Invalid email address!");
								frm.email.focus();
								return false;
							}
							if(frm.agreement.checked == false){
								alert("Please read the Terms and Conditions before submitting the form!");
								frm.agreement.focus();
								return false;
							}
							frm.submit();
						}
}
// Login
function doLogin(){
	
	var frm = document.frmLogin;
	if(frm.user_name.value == ''){
		alert("Please enter username!");
		frm.user_name.focus();
		return false;
	}
	if(frm.user_password.value == ''){
		alert("Please enter password!");
		frm.user_password.focus();
		return false;
	}
	frm.submit();
}

// Register
function doRegister(){
	
	var frm = document.frmRegister;
	if(frm.user_name.value == ''){
		alert("Please enter username!");
		frm.user_name.focus();
		return false;
	}
	if(validateEmail(frm.user_email.value)){
		alert("Please enter a Valid Email!");
		frm.user_email.focus();
		return false;
	}
	if(frm.user_password.value.length < 6){
		alert("Please enter password, minimum 6 characters long!");
		frm.user_password.focus();
		return false;
	}
	frm.submit();
}
function doChangePassword(){
	var frm = document.frmUpdate;
	if(frm.user_password.value.length < 6 ){
		alert("Please enter username, minimum 6 characters long!");
		frm.user_password.focus();
		return false;
	}
}
function doEditProfile(){
	var frm = document.frmUpdate;
	if(frm.user_name.value == ''){
		alert("Please enter username!");
		frm.user_name.focus();
		return false;
	}
	if(validateEmail(frm.user_email.value)){
		alert("Please enter a Valid Email!");
		frm.user_email.focus();
		return false;
	}
}
//Edit My Blog
function doUpdateBlog(){
	var frm = document.frmUpdate;
	if(frm.blog_name.value == ''){
		alert("Please enter a Blog Title!");
		frm.blog_name.focus();
		return false;
	}
	var frm = document.frmUpdate;
	if(frm.blog_description.value.length < 20 ){
		alert("Please enter a Blog Description greater than 20 Characters!");
		frm.blog_description.focus();
		return false;
	}
}

//Edit Player Profile
function doUpdatePlayerProfile(){
	var frm = document.frmUpdate;
	if(frm.player_forename.value == ''){
		alert("Please enter a Forename!");
		frm.player_forename.focus();
		return false;
	}
	var frm = document.frmUpdate;
	if(frm.player_surname.value == ''){
		alert("Please enter a Surname!");
		frm.player_surname.focus();
		return false;
	}
	var frm = document.frmUpdate;
	if(frm.player_position.value == '' ){
		alert("Please enter a Position for this Player!");
		frm.player_position.focus();
		return false;
	}
}

//Edit Blog Entry
function doUpdateBlog(){
	var frm = document.frmUpdate;
	if(frm.blog_entry_title.value == ''){
		alert("Please enter a Blog Entry Title!");
		frm.blog_entry_title.focus();
		return false;
	}
	var frm = document.frmUpdate;
	if(frm.blog_entry_content.value.length < 20 ){
		alert("Please enter Blog Entry Content greater than 20 Characters!");
		frm.blog_entry_content.focus();
		return false;
	}
}

//Delete Friends
function doDeleteFriend(){
	var agree = confirm("Are you sure that you wish to remove this friend?");
	if(agree){
		return true;
	}
	else{
		return false;	
	}
}

// Login Sub
function doLoginSub(){
	
	var frm = document.frmSubLogin;
	if(frm.user_name.value == '' || frm.user_name.value == 'Username'){
		alert("Please enter username!");
		frm.user_name.focus();
		return false;
	}
	if(frm.user_password.value == '' || frm.user_password.value == 'password'){
		alert("Please enter password!");
		frm.user_password.focus();
		return false;
	}
	frm.submit();
}
// Ticket shop
function doSubmitTicketShop(){
	var frm = document.frmTicketShop;
	if(check_empty(frm.ticket_no,'ticket_no')){
		if(checkNumber(frm.ticket_no) == false){
			alert("Invalid number!");
			frm.ticket_no.focus();
			return false;
		}
		frm.submit();
	}
}
// Login
function doCheckoutTicketShop(){
	var frm = document.frmCheckoutTicketShop;
	frm.submit();
}

//--Style Sheet
function doSaveCSS(type){
	var frm = document.frmSaveCSS;
	if(frm.content.value == ''){
		alert("Please input the content!");
		frm.content.focus();
		return;
	}
	frm.type.value = type;
	frm.submit();
}
function doGetBackDefaultCSS(type){
	var f = document.frmSaveCSS;
	if(confirm('Are you sure you want to get back the default CSS?')==true){
		f.type.value = type;
		f.submit();
	}
}

//-- Default image functions
function doUpdateImage(type){
	var f = document.frmDefaultImage;
	if(confirm('Are you sure you want to update your own images?')==true){
		f.type.value = type;
		f.submit();
	}
}
function doGetBackImage(type){
	var f = document.frmDefaultImage;
	if(confirm('Are you sure you want to get back the default images?')==true){
		f.type.value = type;
		f.submit();
	}
}

// SUSPEND
var value = true;
function check_all_suspend(object) {
	var f = object;
	var obj = f.elements["checked_suspend[]"];
	if (obj) {
		if (obj.length) 
			for (i=0;i<obj.length;i++)
				obj[i].checked = value;
		else
			obj.checked = value;
		value = value==false?true:false;
	}
}
function suspend(type) {
	var f = document.frmMySubAccount;
	var obj = f.elements["checked_suspend[]"];
	if (obj) {
		var suspend = false;
		if (obj.length) {
			for (i=0;i<obj.length;i++)
				if (obj[i].checked==true) suspend=true;
		} else {
			if (obj.checked==true) { suspend=true; }
		}
		if (suspend==false) {
			alert("Please check to suspend?");
		} else {
		   if(confirm('Are you sure you want to suspend?')==true){
				f.type.value = type;
				f.submit();
		   }	
		}
	}
}

function doSaveMySubAccount(){
	var frm = document.frmMySubAccount;
	if(frm.user_name.value == ''){
		alert("Please insert the user name!");
		frm.user_name.focus();
		return;
	}
	if(frm.password.value != '' || frm.type.value == 'new'){
		if(frm.password.value.length < 6){
			alert("Password must have at least 6 characters!");
			frm.password.focus();
			return;
		}		
		if(frm.password.value != frm.c_password.value){
			alert("Please confirm the password!");
			frm.c_password.focus();
			return;
		}
	}
	if(frm.first_name.value == ''){
		alert("Please insert the first name!");
		frm.first_name.focus();
		return;
	}
	if(frm.last_name.value == ''){
		alert("Please insert the last name!");
		frm.last_name.focus();
		return;
	}
	if(frm.email.value == ''){
		alert("Please insert the email!");
		frm.email.focus();
		return;
	}
	if(validateEmail(frm.email) == false){
		alert("Invalid email address!");
		frm.email.focus();
		return;
	}
	frm.submit();
}


function doUpdate(){
	var frm = document.frmUpdate;
	if(frm.user_name.value == ''){
		alert("Please insert the user name!");
		frm.user_name.focus();
		return;
	}
	/*
	if(frm.n_password.value != ''){
		if(frm.n_password.value.length < 6){
			alert("Password must have at least 6 characters!");
			frm.n_password.focus();
			return;
		}		
		if(frm.n_password.value != frm.c_password.value){
			alert("Please confirm the password!");
			frm.c_password.focus();
			return;
		}
	}
	*/
	if(frm.first_name.value == ''){
		alert("Please insert the first name!");
		frm.first_name.focus();
		return;
	}
	if(frm.last_name.value == ''){
		alert("Please insert the last name!");
		frm.last_name.focus();
		return;
	}
	
	if(frm.email.value == ''){
		alert("Please insert the email!");
		frm.email.focus();
		return;
	}
	if(validateEmail(frm.email) == false){
		alert("Invalid email address!");
		frm.email.focus();
		return;
	}
	frm.submit();
}

// function changer_update_password here
function doUpdate_pass(){
	var frm = document.frmUpdate_pass;
	if(frm.o_password.value == '' ){
		alert("Please insert the password old !");
		frm.o_password.focus();
		return;
	}
	if(frm.n_password.value != ''){
		if(frm.n_password.value.length < 6){
			alert("Password must have at least 6 characters!");
			frm.n_password.focus();
			return;
		}		
		if(frm.c_password.value != frm.n_password.value){
			alert("Please confirm the password!");
			frm.c_password.focus();
			return;
		}
	}
	frm.submit();
}
/*
 ### jQuery Star Rating Plugin v3.13 - 2009-03-26 ###
 * Home: http://www.fyneworks.com/jquery/star-rating/
 * Code: http://code.google.com/p/jquery-star-rating-plugin/
 *
	* Dual licensed under the MIT and GPL licenses:
 *   http://www.opensource.org/licenses/mit-license.php
 *   http://www.gnu.org/licenses/gpl.html
 ###
*/

/*# AVOID COLLISIONS #*/
;if(window.jQuery) (function($){
/*# AVOID COLLISIONS #*/
	
	// IE6 Background Image Fix
	if ($.browser.msie) try { document.execCommand("BackgroundImageCache", false, true)} catch(e) { };
	// Thanks to http://www.visualjquery.com/rating/rating_redux.html
	
	// plugin initialization
	$.fn.rating = function(options){
		if(this.length==0) return this; // quick fail
		
		// Handle API methods
		if(typeof arguments[0]=='string'){
			// Perform API methods on individual elements
			if(this.length>1){
				var args = arguments;
				return this.each(function(){
					$.fn.rating.apply($(this), args);
    });
			};
			// Invoke API method handler
			$.fn.rating[arguments[0]].apply(this, $.makeArray(arguments).slice(1) || []);
			// Quick exit...
			return this;
		};
		
		// Initialize options for this call
		var options = $.extend(
			{}/* new object */,
			$.fn.rating.options/* default options */,
			options || {} /* just-in-time options */
		);
		
		// Allow multiple controls with the same name by making each call unique
		$.fn.rating.calls++;
		
		// loop through each matched element
		this
		 .not('.star-rating-applied')
			.addClass('star-rating-applied')
		.each(function(){
			
			// Load control parameters / find context / etc
			var control, input = $(this);
			var eid = (this.name || 'unnamed-rating').replace(/\[|\]/g, '_').replace(/^\_+|\_+$/g,'');
			var context = $(this.form || document.body);
			
			// FIX: http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=23
			var raters = context.data('rating');
			if(!raters || raters.call!=$.fn.rating.calls) raters = { count:0, call:$.fn.rating.calls };
			var rater = raters[eid];
			
			// if rater is available, verify that the control still exists
			if(rater) control = rater.data('rating');
			
			if(rater && control)//{// save a byte!
				// add star to control if rater is available and the same control still exists
				control.count++;
				
			//}// save a byte!
			else{
				// create new control if first star or control element was removed/replaced
				
				// Initialize options for this raters
				control = $.extend(
					{}/* new object */,
					options || {} /* current call options */,
					($.metadata? input.metadata(): ($.meta?input.data():null)) || {}, /* metadata options */
					{ count:0, stars: [], inputs: [] }
				);
				
				// increment number of rating controls
				control.serial = raters.count++;
				
				// create rating element
				rater = $('<span class="star-rating-control"/>');
				input.before(rater);
				
				// Mark element for initialization (once all stars are ready)
				rater.addClass('rating-to-be-drawn');
				
				// Accept readOnly setting from 'disabled' property
				if(input.attr('disabled')) control.readOnly = true;
				
				// Create 'cancel' button
				rater.append(
					control.cancel = $('<div class="rating-cancel"><a title="' + control.cancel + '">' + control.cancelValue + '</a></div>')
					.mouseover(function(){
						$(this).rating('drain');
						$(this).addClass('star-rating-hover');
						//$(this).rating('focus');
					})
					.mouseout(function(){
						$(this).rating('draw');
						$(this).removeClass('star-rating-hover');
						//$(this).rating('blur');
					})
					.click(function(){
					 $(this).rating('select');
					})
					.data('rating', control)
				);
				
			}; // first element of group
			
			// insert rating star
			var star = $('<div class="star-rating rater-'+ control.serial +'"><a title="' + (this.title || this.value) + '">' + this.value + '</a></div>');
			rater.append(star);
			
			// inherit attributes from input element
			if(this.id) star.attr('id', this.id);
			if(this.className) star.addClass(this.className);
			
			// Half-stars?
			if(control.half) control.split = 2;
			
			// Prepare division control
			if(typeof control.split=='number' && control.split>0){
				var stw = ($.fn.width ? star.width() : 0) || control.starWidth;
				var spi = (control.count % control.split), spw = Math.floor(stw/control.split);
				star
				// restrict star's width and hide overflow (already in CSS)
				.width(spw)
				// move the star left by using a negative margin
				// this is work-around to IE's stupid box model (position:relative doesn't work)
				.find('a').css({ 'margin-left':'-'+ (spi*spw) +'px' })
			};
			
			// readOnly?
			if(control.readOnly)//{ //save a byte!
				// Mark star as readOnly so user can customize display
				star.addClass('star-rating-readonly');
			//}  //save a byte!
			else//{ //save a byte!
			 // Enable hover css effects
				star.addClass('star-rating-live')
				 // Attach mouse events
					.mouseover(function(){
						$(this).rating('fill');
						$(this).rating('focus');
					})
					.mouseout(function(){
						$(this).rating('draw');
						$(this).rating('blur');
					})
					.click(function(){
						$(this).rating('select');
					})
				;
			//}; //save a byte!
			
			// set current selection
			if(this.checked)	control.current = star;
			
			// hide input element
			input.hide();
			
			// backward compatibility, form element to plugin
			input.change(function(){
    $(this).rating('select');
   });
			
			// attach reference to star to input element and vice-versa
			star.data('rating.input', input.data('rating.star', star));
			
			// store control information in form (or body when form not available)
			control.stars[control.stars.length] = star[0];
			control.inputs[control.inputs.length] = input[0];
			control.rater = raters[eid] = rater;
			control.context = context;
			
			input.data('rating', control);
			rater.data('rating', control);
			star.data('rating', control);
			context.data('rating', raters);
  }); // each element
		
		// Initialize ratings (first draw)
		$('.rating-to-be-drawn').rating('draw').removeClass('rating-to-be-drawn');
		
		return this; // don't break the chain...
	};
	
	/*--------------------------------------------------------*/
	
	/*
		### Core functionality and API ###
	*/
	$.extend($.fn.rating, {
		// Used to append a unique serial number to internal control ID
		// each time the plugin is invoked so same name controls can co-exist
		calls: 0,
		
		focus: function(){
			var control = this.data('rating'); if(!control) return this;
			if(!control.focus) return this; // quick fail if not required
			// find data for event
			var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );
   // focus handler, as requested by focusdigital.co.uk
			if(control.focus) control.focus.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
		}, // $.fn.rating.focus
		
		blur: function(){
			var control = this.data('rating'); if(!control) return this;
			if(!control.blur) return this; // quick fail if not required
			// find data for event
			var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null );
   // blur handler, as requested by focusdigital.co.uk
			if(control.blur) control.blur.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]);
		}, // $.fn.rating.blur
		
		fill: function(){ // fill to the current mouse position.
			var control = this.data('rating'); if(!control) return this;
			// do not execute when control is in read-only mode
			if(control.readOnly) return;
			// Reset all stars and highlight them up to this element
			this.rating('drain');
			this.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-hover');
		},// $.fn.rating.fill
		
		drain: function() { // drain all the stars.
			var control = this.data('rating'); if(!control) return this;
			// do not execute when control is in read-only mode
			if(control.readOnly) return;
			// Reset all stars
			control.rater.children().filter('.rater-'+ control.serial).removeClass('star-rating-on').removeClass('star-rating-hover');
		},// $.fn.rating.drain
		
		draw: function(){ // set value and stars to reflect current selection
			var control = this.data('rating'); if(!control) return this;
			// Clear all stars
			this.rating('drain');
			// Set control value
			if(control.current){
				control.current.data('rating.input').attr('checked','checked');
				control.current.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-on');
			}
			else
			 $(control.inputs).removeAttr('checked');
			// Show/hide 'cancel' button
			control.cancel[control.readOnly || control.required?'hide':'show']();
			// Add/remove read-only classes to remove hand pointer
			this.siblings()[control.readOnly?'addClass':'removeClass']('star-rating-readonly');
		},// $.fn.rating.draw
		
		
		
		
		
		select: function(value,wantCallBack){ // select a value
					
					// ***** MODIFICATION *****
					// Thanks to faivre.thomas - http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=27
					//
					// ***** LIST OF MODIFICATION *****
					// ***** added Parameter wantCallBack : false if you don't want a callback. true or undefined if you want postback to be performed at the end of this method'
					// ***** recursive calls to this method were like : ... .rating('select') it's now like .rating('select',undefined,wantCallBack); (parameters are set.)
					// ***** line which is calling callback
					// ***** /LIST OF MODIFICATION *****
			
			var control = this.data('rating'); if(!control) return this;
			// do not execute when control is in read-only mode
			if(control.readOnly) return;
			// clear selection
			control.current = null;
			// programmatically (based on user input)
			if(typeof value!='undefined'){
			 // select by index (0 based)
				if(typeof value=='number')
 			 return $(control.stars[value]).rating('select',undefined,wantCallBack);
				// select by literal value (must be passed as a string
				if(typeof value=='string')
					//return
					$.each(control.stars, function(){
						if($(this).data('rating.input').val()==value) $(this).rating('select',undefined,wantCallBack);
					});
			}
			else
				control.current = this[0].tagName=='INPUT' ?
				 this.data('rating.star') :
					(this.is('.rater-'+ control.serial) ? this : null);

			// Update rating control state
			this.data('rating', control);
			// Update display
			this.rating('draw');
			// find data for event
			var input = $( control.current ? control.current.data('rating.input') : null );
			// click callback, as requested here: http://plugins.jquery.com/node/1655
					
					// **** MODIFICATION *****
					// Thanks to faivre.thomas - http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=27
					//
					//old line doing the callback :
					//if(control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event
					//
					//new line doing the callback (if i want :)
					if((wantCallBack ||wantCallBack == undefined) && control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event
					//to ensure retro-compatibility, wantCallBack must be considered as true by default
					// **** /MODIFICATION *****
					
  },// $.fn.rating.select
		
		
		
		
		
		readOnly: function(toggle, disable){ // make the control read-only (still submits value)
			var control = this.data('rating'); if(!control) return this;
			// setread-only status
			control.readOnly = toggle || toggle==undefined ? true : false;
			// enable/disable control value submission
			if(disable) $(control.inputs).attr("disabled", "disabled");
			else     			$(control.inputs).removeAttr("disabled");
			// Update rating control state
			this.data('rating', control);
			// Update display
			this.rating('draw');
		},// $.fn.rating.readOnly
		
		disable: function(){ // make read-only and never submit value
			this.rating('readOnly', true, true);
		},// $.fn.rating.disable
		
		enable: function(){ // make read/write and submit value
			this.rating('readOnly', false, false);
		}// $.fn.rating.select
		
 });
	
	/*--------------------------------------------------------*/
	
	/*
		### Default Settings ###
		eg.: You can override default control like this:
		$.fn.rating.options.cancel = 'Clear';
	*/
	$.fn.rating.options = { //$.extend($.fn.rating, { options: {
			cancel: 'Cancel Rating',   // advisory title for the 'cancel' link
			cancelValue: '',           // value to submit when user click the 'cancel' link
			split: 0,                  // split the star into how many parts?
			
			// Width of star image in case the plugin can't work it out. This can happen if
			// the jQuery.dimensions plugin is not available OR the image is hidden at installation
			starWidth: 16//,
			
			//NB.: These don't need to be pre-defined (can be undefined/null) so let's save some code!
			//half:     false,         // just a shortcut to control.split = 2
			//required: false,         // disables the 'cancel' button so user can only select one of the specified values
			//readOnly: false,         // disable rating plugin interaction/ values cannot be changed
			//focus:    function(){},  // executed when stars are focused
			//blur:     function(){},  // executed when stars are focused
			//callback: function(){},  // executed when a star is clicked
 }; //} });
	
	/*--------------------------------------------------------*/
	
	/*
		### Default implementation ###
		The plugin will attach itself to file inputs
		with the class 'multi' when the page loads
	*/
	$(function(){
	 $('input[type=radio].star').rating();
	});
	
	
	
/*# AVOID COLLISIONS #*/
})(jQuery);
/*# AVOID COLLISIONS #*/

  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  createCookie( 'document_width', myWidth, 7 );
  createCookie( 'document_height', myHeight,7 );

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
