function getParameter( name )
{
  var regexS = "[\\?&]"+name+"=([^&]*)";
  var regex = new RegExp( regexS );
  var tmpURL = window.location.href;
  var results = regex.exec( tmpURL );
  if( results == null )
    return "";
  else
    return results[1];
}

function openPane( )
{
  var paramOpenPane= getParameter('openPane');
  
  if(paramOpenPane=='true'){
	  openSelectorPane();
  }
}

function openSelectorPane()
{
	window.scrollTo(0,0);
    wep.openWepPane('Shop', 'mcr.shop.pricingandavailability.id');
}

function openPricingPane()
{
	window.scrollTo(0,0);
    wep.openWepPane('Shop', 'mcr.shop.pricingandavailability.id');
}

function openLocatorPane()
{
	window.scrollTo(0,0);
	wep.openWepPane("Shop", 'odw.dealerLocatorEntry.id');
}

function reloadPage(paramOpenPane) { 
	var reloadLocation=location.href;
	var indexOfDies=reloadLocation.indexOf('#');
	if(indexOfDies != -1){
		reloadLocation=reloadLocation.substring(0,indexOfDies);
	}
	if(paramOpenPane=='true'){
		if(reloadLocation.indexOf('openPane') == -1){
			var seperator='';
		    if(reloadLocation.indexOf('?')>-1){
		    	separator = '&';
		    }else {
		    	separator = '?';
		    }
		    window.location = reloadLocation+separator+'openPane=true';
		}else{
			window.location = reloadLocation;
		}
	}else{
	 	if(reloadLocation.indexOf('?openPane=true&') != -1){
			reloadLocation=reloadLocation.replace('openPane=true&',"");
		}
		else if(reloadLocation.indexOf('?openPane=true') != -1){
			reloadLocation=reloadLocation.replace('?openPane=true',"");
		}
		else if(reloadLocation.indexOf('&openPane=true') != -1){
			reloadLocation=reloadLocation.replace('&openPane=true',"");
		} 
	    window.location = reloadLocation;
	}
}

function setSessionCookie(c_name,value){
	document.cookie=c_name+ "=" +escape(value);
}

function getCookie(c_name){
	if (document.cookie.length>0)
	  {
	  c_start=document.cookie.indexOf(c_name + "=");
	  if (c_start!=-1)
	    { 
	    c_start=c_start + c_name.length+1; 
	    c_end=document.cookie.indexOf(";",c_start);
	    if (c_end==-1) c_end=document.cookie.length;
	    return unescape(document.cookie.substring(c_start,c_end));
	    } 
	  }
	return "";
}


