var dest_province = "";
var dest_page = "";
var dest_temp = "";









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 "";
	}


function checkCookie()
	{
	provinceCookie=getCookie('provinceCookie');
	if (provinceCookie!=null && provinceCookie!="")
		return true;
			else
				return false;
	}

function deleteCookie()
	{
	document.cookie = "provinceCookie" + "=; expires=Thu, 01-Jan-70 00:00:01 GMT;";
	alert("Your Province Selection has been reset");
	}
	

function destination_test( id, anchorId )
	{
	destination_page( id );
	if( !checkCookie() )
		$("#basic-modal-content").modal();
			else
				{
				dest_province = getCookie( "provinceCookie" )
				if( dest_province == ""  || dest_province == null )
					$("#basic-modal-content").modal();
						else
//							if( anchorId )  	
								destination_location( anchorId )
		//							else
	//									destination_location( '' )
									
				}

	return false;
	}

	
function has_cookie( prov )	
	{
	if( checkCookie() )
		{
		dest_province = getCookie( "provinceCookie" )
		if( dest_province != prov )
			location.href="index.html";
				
		}
		else	
			location.href="index.html";
	}
	


function load_destination( pg )	
	{
	destination_page( pg );

	if( checkCookie() )
		{
		dest_province = getCookie( "provinceCookie" )
		if( dest_province != ""  || dest_province != null )
			destination_location()
		}


	}
function destination_temp( v )
	{
	dest_temp = v
	}

function destination_page( pg )
	{
	dest_page = pg
	}

function destination_province( prov )
	{
	dest_province = prov;
	setCookie( "provinceCookie", dest_province, 30 );
	}

function destination_continue( prov )
	{
	destination_province( prov );
	destination_location();	
	}

function destination_location( anchorID )
	{
	if( dest_page == "" || dest_province == "" )
		return;
	
	if( anchorID )  	
		document.location = dest_page +".html?loc="+dest_province+"#"+anchorID;
			else
			    document.location = dest_page + ".html?loc=" + dest_province;
	}
	




	
