// collapse individual elements
var activeForm = "mainForm_1";

function collapseElem(obj)
{
	// var el = document.getElementById(obj);
	// el.style.display = 'none';
	jQuery('#' + obj).hide();
}

// expand next element

function expandElem(obj, obj1, doCheck)
{
	if (activeForm != null)
	{
		if (doCheck && !subChkNext(activeForm))
		{
			return;
		}
		collapseElem(activeForm);
	}
	// var el = document.getElementById(obj);
	// el.style.display = '';
	jQuery('#' + obj).show();
	
	activeForm = obj;
	if (obj1 != null)
	{
		jQuery('#' + obj1).focus();
	}
}

// collapse all elements, except the first one
function collapseAll()
{
	// change the following line to reflect the number of pages
	var numFormPages = 4;
	
	for (i = 2; i <= numFormPages; i++)
	{
		var currPageId = ('mainForm_' + i);
		// collapseElem(currPageId);
		var el = document.getElementById(currPageId);
		el.style.display = 'none';
	}
}

// run the collapseAll function on page load
// window.onload = collapseAll;
jQuery(document).ready(function()
{
	jQuery('#username').focus();
});

var autovalidateOnFocus = false;
function getObj(id)
{
	
	obj = document.getElementById(id);
	return obj;
}

function flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace)
{
	var x = jQuery(x);
	var id = x.attr("id");
	x.css("background-color", "#fcc");
	showWarning(x, message, "#822", 290, true, absX, absY, absParent, relX, relY,rootPlace);
	if (autovalidateOnFocus)
		x.focus();
	
}

function showWarning(x, message, color, offsetLeft, calcParentOffset, absX, absY, absParent, relX, relY, rootPlace)
{
	if (x.length > 0)
	{
		x = jQuery(x[0]);
	}
	
	var id = x.attr("id");
	var offsetTop=null;
	var jqString = '#' + id + 'Label_alert'
	var idString = id + 'Label_alert'
	jQuery(".alertBox").remove();
	var fieldPos = x.offset();
	if(relX!=null)
	{
		offsetLeft = relX;
	}
	if(relY!=null)
	{
		offsetTop = relY;
	}
	calcParentOffset = (absParent==null || absParent!="0");
	if (calcParentOffset)
	{
		fieldPos.top = x.parent().offset().top - x.offsetParent().offset().top;
		fieldPos.left = x.parent().offset().left - x.offsetParent().offset().left + x.parent().width()+10;
	}
	else
	{
		if(offsetTop!=null)
		fieldPos.top = Math.abs(fieldPos.top)+ Math.abs(offsetTop);
		fieldPos.left = Math.abs(fieldPos.left)+ Math.abs(offsetLeft);
		
	}
	var appString = "<div id=\"" + idString
			+ "\" class=\"alertBox\" style=\"top:0px;left:0px;background-color:white;position:absolute;display:block;border:1px solid " + color
			+ ";width:220px;z-index:999;\"><p class=\"alertMsg\" style=\"color:" + color + ";padding:3px;margin:0;font-size:11px\">" + message
			+ "</p></div>";
	if (rootPlace=='1')
	{
		jQuery('body').append(appString);
		
	}
	else if(rootPlace)
	{
		var appString = "<div id=\"" + idString
		+ "\" class=\"alertBox\" style=\"top:0px;left:0px;background-color:white;position:relative;display:block;border:1px solid " + color
		+ ";width:220px;z-index:999;\"><p class=\"alertMsg\" style=\"color:" + color + ";padding:3px;margin:0;font-size:11px\">" + message
		+ "</p></div>";

		jQuery('#'+rootPlace).append(appString);
		jQuery('#'+idString).focus();
		
	}
	else if (calcParentOffset)
	{
		// jQuery("#" + activeForm).parent().append(appString);
		x.parent().append(appString);
	}
	else
	{
		x.parent().append(appString);
	}
	if (absX != null && absX != "")
	{
		if(absY!=null)
		{
			jQuery(jqString).css("top", absY + "px");
			
		}
		jQuery(jqString).css("left", absX + "px");
		
	}
	else
	{
		jQuery(jqString).css("top", (fieldPos.top) + "px");
		jQuery(jqString).css("left", (fieldPos.left) + "px");
		
	}
}


function flagFieldWarning(x, message2, id, absX, absY, absParent, relX, relY,rootPlace)
{
	var x = jQuery(x);
	// x.css("background-color", "#fcc");
	
	if (autovalidateOnFocus)
		x.focus();
	showWarning(x, message2, "#822", 490, true, absX, absY, absParent, relX, relY,rootPlace);
	// alert(message);
	
}
function flagFieldWarningRadio(x, message, id, absX, absY, absParent, relX, relY,rootPlace)
{
	var x = jQuery(x);
	var id = x.attr("id");
	// x.parent().css("background-color", "#fcc");
	showWarning(x, message, "#822", 0, true, absX, absY, absParent, relX, relY,rootPlace);
	if (autovalidateOnFocus)
		x.focus();
	// alert(message);
	
}
function unflagField(x)
{
	x.css("background-color", "");
	jQuery('.alertBox').remove();
	
}
function unflagFieldWarningRadio(x)
{
	var id = x.attr("id");
	x.parent().css("background-color", "");
	jQuery('#' + id + 'Label_alert').remove();
	
}

function chkLive(obj)
{
	var formArray = jQuery(obj);
	autovalidateOnFocus = true;
	return doValidate(formArray, null, true);
}
function chkLiveNoFocus(obj, refocus)
{
	var formArray = jQuery(obj);
	autovalidateOnFocus = false;
	var res = doValidate(formArray, null, true);
	if (refocus)
	{
		obj.focus();
	}
	
	return res;
}

function submitContact(id,action)
{
	if(subChk(id))
	{
		var jqForm = jQuery('#' + id);
		jqForm.attr("action",action);
		jqForm.submit();
	}
}


function subChk(id)
{
	var jqForm = jQuery('#' + id);
	var jqId = "#" + id;
	var formArray = "#" + id + " :input";
	var formArray = jQuery(":input", document.forms[id]);
	autovalidateOnFocus = true;
	checkResult =  doValidate(formArray)
	return  checkResult;
	
}
function subChkNext(id, idf)
{
	var jqForm = jQuery('#' + id);
	var jqId = "#" + id;
	var formArray = "#" + id + " :input";
	var formArray = jQuery("#" + id + " :input", document.forms[idf]);
	autovalidateOnFocus = true;
	
	return doValidate(formArray);
}

function doValidate(formArray, loadMarkOnly, isLive)
{
	// myId = obj.id;
	var rgxNum = /^[0-9]+$/;
	var rgxTel = /^[1-9][0-9]+$/;
	var rgxTxt = /\S+/;
	var rgxPasswd = /[0-9a-zA-Z]{5,}/;
	var rgxEmail = /\S+@\S+\.\S+/;
	var rgxAnsi2 = /\S+/;
	var rgxAnsi = /\S+/;
	var rgxDate = /^([0-2][0-9]|[3][0-1])([.])([0][0-9]|[1][0-2])([.])([12][8-9]|[2][0])([0-9][0-9])$/
	var rgxTime = /^([0-1][0-9]|[2][0-3]):([0-5][0-9])$/

	var x = null;
	var chk = true;
	for (i = 0; i < formArray.length && chk; i++)
	{
		id = formArray[i].name;
		var x = jQuery(formArray[i]);
		if (true)
		{
			var nx = x.attr("val");
			var nx2 = x.attr("emp");
			var nx3 = x.attr("dependant");
			var nx4 = x.attr("identical");
			var nx5 = x.attr("onechecked");
			var nx6 = (x.attr("markonly") == 1 || (loadMarkOnly != null && loadMarkOnly) ? true : false);
			var nx7 = x.attr("validmin");
			var nx8 = x.attr("switchempty");
			var nx9 = x.attr("depselect");
			var nx10 = x.attr("allchecked");
			var nx11 = x.attr("url");
			var nx12 = x.attr("pname");
			var absX = x.attr("absx");
			var absY = x.attr("absy");
			var relX = x.attr("relx");
			var relY = x.attr("rely");
			var rootPlace = x.attr("rootPlace");
			var absParent = x.attr("absParent");
			
			// Prüfung darf Feld leer sein (=0)
			if (nx2 != null && nx2 == 0 && x.val() == "")
			{
				
			}
			// Prüfung abhängige Checkbox gesetzt?
			else if (nx3 != null && document.getElementById(nx3) && !document.getElementById(nx3).checked)
			{
			}
			else if (nx9 != null && document.getElementById(nx9) && document.getElementById(nx9).selectedIndex == 0)
			{
			}
			
			else
			{
				var message = x.attr("message");
				var message2 = x.attr("message2");
				while (message && message.indexOf("|") > -1)
				{
					message = message.replace(/[|]+/, "<br>");
				}
				while (message2 && message2.indexOf("|") > -1)
				{
					message2 = message2.replace(/[|]+/, "<br>");
				}
				if (nx != null && nx != "")
				{
					if (nx == 'txt')
					{
						if (!rgxTxt.test(x.val()))
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'num')
					{
						if (!rgxNum.test(x.val()))
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'tel')
					{
						if (!rgxTel.test(x.val()))
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'eml')
					{
						if (!rgxEmail.test(x.val()))
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'ansi')
					{
						if (!rgxAnsi.test(x.val()))
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'ansi2')
					{
						if (!rgxAnsi2.test(x.val()))
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'date')
					{
						if (!rgxDate.test(x.val()))
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'time')
					{
						if (!rgxTime.test(x.val()))
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'passwd')
					{
						if (!rgxPasswd.test(x.val()))
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'samecontent')
					{
						if (nx4 != null)
						{
							idcheck = document.getElementById(nx4);
							if (idcheck && idcheck.value != x.val())
							{
								flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
								chk = false || nx6;
							}
							else
							{
								unflagField(x);
							}
						}
					}
					else if (nx == 'selectbox0')
					{
						if (x[0].selectedIndex == 0)
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'selectboxlast')
					{
						if (x[0].selectedIndex == x[0].options.length - 1)
						{
							if (nx8 != null && nx8 != "")
							{
								y = jQuery('#' + nx8);
								if (y.length > 0)
								{
									y.attr("empty", "1");
								}
							}
						}
						else
						{
							if (nx8 != null && nx8 != "")
							{
								y = jQuery('#' + nx8);
								if (y.length > 0)
								{
									y.attr("empty", "0");
									unflagField(y);
								}
							}
						}
						if (x[0].selectedIndex == 0)
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'validmin')
					{
						var xVal = x.val();
						var checkValidMin = Date.parse(x.attr("validmin"));
						var givenDate = Date.parse(xVal);
						if (!rgxDate.test(x.val()))
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else if (checkValidMin > givenDate)
						{
							flagFieldWarning(x, message2, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
							
						}
						
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'radioSelected')
					{
						if (nx5 != null)
						{
							var radioArray = jQuery('input[onechecked="' + nx5 + '"]');
							var oneChecked = false
							for (ix = 0; ix < radioArray.length && !oneChecked; ix++)
							{
								if (radioArray[ix].checked)
								{
									oneChecked = true;
								}
							}
							if (!oneChecked)
							{
								if (radioArray.length > 0)
									flagFieldWarningRadio(radioArray, message, radioArray[0].id, absX, absY, absParent, relX, relY,rootPlace);
								chk = false || nx6;
								
							}
							else
							{
								if (radioArray.length > 0)
									unflagFieldWarningRadio(radioArray, message, radioArray[0].id);
								
							}
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'checkboxCheckedAll')
					{
						if (nx10 != null)
						{
							var radioArray = jQuery('input[allchecked="' + nx10 + '"]');
							var oneChecked = true
							for (ix = 0; ix < radioArray.length && oneChecked; ix++)
							{
								if (!radioArray[ix].checked)
								{
									oneChecked = false;
								}
							}
							if (!oneChecked)
							{
								if (radioArray.length > 0)
									flagFieldWarningRadio(radioArray, message, radioArray[0].id, absX, absY, absParent, relX, relY,rootPlace);
								chk = false || nx6;
								
							}
							else
							{
								if (radioArray.length > 0)
									unflagFieldWarningRadio(radioArray, message, radioArray[0].id);
								
							}
						}
						else
						{
							unflagField(x);
						}
					}
					else if (nx == 'checkboxChecked')
					{
						if (!x[0].checked)
						{
							flagFieldWarningRadio(x, message, x.id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							unflagFieldWarningRadio(x, message, x.id);
						}
					}
					else if (nx == 'json')
					{
						// debugger;
						if (!rgxTxt.test(x.val()))
						{
							flagField(x, message, id, absX, absY, absParent, relX, relY,rootPlace);
							chk = false || nx6;
						}
						else
						{
							if (!isLive)
							{
								jQuery.ajaxSetup(
								{
									async : false
								});
								jQuery.getJSON(baseUrl + "serverValidation.php?" + nx12 + "=" + x.val(), function(data)
								{
									if (data.msg != "OK")
									{
										flagField(x, data.msg, x.id, absX, absY, absParent, relX, relY,rootPlace);
										chk = false || nx6;
									}
									else
									{
										unflagField(x, message, x.id);
									}
								});
								
							}
							else
							{
								unflagField(x, message, x.id);
							}
						}
					}
				}
			}
		}
		else
		{
			alert("Object Error: " + id);
			chk = false;
		}
	}
	return (isLive ? true : chk);
}
function showVideo(vParam)
{
	var objString = '<div id="vDisplay" class="csmDialog"><object width="425" height="344"><param name="movie" value="http://www.youtube-nocookie.com/'
			+ vParam
			+ '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube-nocookie.com/'
			+ vParam
			+ '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object></div>';
	jQuery('body').append(objString);
	jQuery('#vDisplay').dialog(
	{
		height : 465,
		width : 464,
		position :
		[ 'center', 100 ],
		modal : true,
		title : "Videoplayer",
		dialogClass:'csmDialog',
		
		buttons :
		{
//			'Ok' : function()
//			{
//				jQuery(this).dialog('close');
//			}
		}
	});
	jQuery('#vDisplay').bind('dialogclose', function(event, ui)
	{
		jQuery(this).dialog('destroy');
		jQuery('#vDisplay').remove();
	});
	return false;
}
function showIssue(vParam)
{
	var objString = '<div id="pdfDisplay"><object style="width:600px;height:424px" ><param name="movie" value="http://static.issuu.com/webembed/viewers/style1/v1/IssuuViewer.swf?mode=embed&amp;layout=http%3A%2F%2Fskin.issuu.com%2Fv%2Fcolor%2Flayout.xml&amp;backgroundColor=555555&amp;showFlipBtn=true&amp;'
			+ vParam
			+ '&amp;loadingInfoText=nextbusiness-IT&amp;et=1242297050118&amp;er=64" /><param name="allowfullscreen" value="true"/><param name="menu" value="false"/><embed src="http://static.issuu.com/webembed/viewers/style1/v1/IssuuViewer.swf" type="application/x-shockwave-flash" allowfullscreen="true" menu="false" style="width:600px;height:424px" flashvars="mode=embed&amp;layout=http%3A%2F%2Fskin.issuu.com%2Fv%2Fcolor%2Flayout.xml&amp;backgroundColor=555555&amp;showFlipBtn=true&amp;'
			+ vParam + '&amp;loadingInfoText=nextbusiness-IT&amp;et=1242297050118&amp;er=64" /></object></div>';
	jQuery('body').append(objString);
	jQuery('#pdfDisplay').dialog(
	{
		height : 550,
		width : 630,
		position :
		[ 'center', 100 ],
		modal : true,
		title : "PDF Preview",
		buttons :
		{
			'Ok' : function()
			{
				jQuery(this).dialog('close');
			}
		}
	});
	jQuery('#pdfDisplay').bind('dialogclose', function(event, ui)
	{
		jQuery(this).dialog('destroy');
		jQuery('#pdfDisplay').remove();
	});
	
}
function showRegReminder()
{
	jQuery('#logAdv').dialog(
	{
		height : 555,
		width : 590,
		position :
		[ 'center', 100 ],
		title : "Hinweis",
		modal : true,
		beforeclose : function(event, ui)
		{
			jQuery('#logAdv').dialog('destroy');
			return false;
		},
		buttons :
		{
			'Ok' : function()
			{
				jQuery('#logAdv').dialog('destroy');
			}
		}
	});
	return false;
}

function displayPromo()
{
	if (jQuery.cookie("displayPromo") != null)
	{
		return false;
	}
	jQuery('#promoLayer').dialog(
	{
		height : 555,
		width : 590,
		position :
		[ 'center', 100 ],
		title : "Hinweis",
		modal : true,
		beforeclose : function(event, ui)
		{
			jQuery('#promoLayer').dialog('destroy');
			return false;
		},
		buttons :
		{
			'Ok' : function()
			{
				jQuery('#promoLayer').dialog('destroy');
			}
		}
	});
	jQuery.cookie("displayPromo", "1");
	return false;
}

jQuery(document).ready(function()
{
	jQuery(":input[val]", document.forms[1]).keyup(function()
			{
				chkLiveNoFocus(this)
			});
	jQuery(":input[val]", document.forms[1]).blur(function()
			{
				chkLiveNoFocus(this)
			});
	// jQuery(":input[val=json]", document.forms[1]).blur( function()
		// {
		// chkLiveNoFocus(this, true)
		// });
		jQuery(":input[val]", document.forms[1]).click(function()
		{
			chkLiveNoFocus(this)
		});
		// jQuery(":input[onechecked]",
		// document.forms[1]).change(function(){chkLiveNoFocus(this)});
		jQuery(":input[onechecked]", document.forms[1]).click(function()
		{
			chkLiveNoFocus(this)
		});
		jQuery("select[val]", document.forms[1]).change(function()
		{
			chkLiveNoFocus(this)
		});
		
		// OnLoad Markierung der fehlerhaften Felder
		/*
		 * jQuery(":input[empty=1]",
		 * document.forms[1]).css("background-color","#EECED0");
		 * jQuery(":input[markonly]",
		 * document.forms[1]).css("background-color","#FFCF8A");
		 * jQuery(":input[dependant]",
		 * document.forms[1]).css("background-color","#fff");
		 * jQuery("select[val]",
		 * document.forms[1]).css("background-color","#EECED0");
		 * jQuery("select[markonly]",
		 * document.forms[1]).css("background-color","#FFCF8A");
		 * jQuery(":input[dependant]",
		 * document.forms[1]).css("background-color","#fff");
		 * 
		 * doValidate(formArray = jQuery(":input", document.forms[1]), true);
		 */
		// Ende OnLoad Markierung
	}

);

/**
 * Cookie plugin
 * 
 * Copyright (c) 2006 Klaus Hartl (stilbuero.de) Dual licensed under the MIT and
 * GPL licenses: http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * 
 */

/**
 * Create a cookie with the given name and value and other optional parameters.
 * 
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain:
 *          'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to
 *       use the same path and domain used when the cookie was set.
 * 
 * @param String
 *            name The name of the cookie.
 * @param String
 *            value The value of the cookie.
 * @param Object
 *            options An object literal containing key/value pairs to provide
 *            optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date
 *         from now on in days or a Date object. If a negative value is
 *         specified (e.g. a date in the past), the cookie will be deleted. If
 *         set to null or omitted, the cookie will be a session cookie and will
 *         not be retained when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default:
 *         path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie
 *         (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be
 *         set and the cookie transmission will require a secure protocol (like
 *         HTTPS).
 * @type undefined
 * 
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given name.
 * 
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 * 
 * @param String
 *            name The name of the cookie.
 * @return The value of the cookie.
 * @type String
 * 
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function(name, value, options)
{
	if (typeof value != 'undefined')
	{ // name and value given, set cookie
		options = options || {};
		if (value === null)
		{
			value = '';
			options.expires = -1;
		}
		var expires = '';
		if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString))
		{
			var date;
			if (typeof options.expires == 'number')
			{
				date = new Date();
				date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
			}
			else
			{
				date = options.expires;
			}
			expires = '; expires=' + date.toUTCString(); // use expires
			// attribute,
			// max-age is not
			// supported by IE
		}
		// CAUTION: Needed to parenthesize options.path and options.domain
		// in the following expressions, otherwise they evaluate to undefined
		// in the packed version for some reason...
		var path = options.path ? '; path=' + (options.path) : '';
		var domain = options.domain ? '; domain=' + (options.domain) : '';
		var secure = options.secure ? '; secure' : '';
		document.cookie =
		[ name, '=', encodeURIComponent(value), expires, path, domain, secure ].join('');
	}
	else
	{ // only name given, get cookie
		var cookieValue = null;
		if (document.cookie && document.cookie != '')
		{
			var cookies = document.cookie.split(';');
			for ( var i = 0; i < cookies.length; i++)
			{
				var cookie = jQuery.trim(cookies[i]);
				// Does this cookie string begin with the name we want?
				if (cookie.substring(0, name.length + 1) == (name + '='))
				{
					cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
					break;
				}
			}
		}
		return cookieValue;
	}
};

