var CurrentPictureID=1;


function SetCookie(name,value)
{
	var Days=30;
	var exp=new Date();
	exp.setTime(exp.getTime() + Days*24*60*60*1000);
	document.cookie=name+"="+escape(value)+";expires="+ exp.toGMTString();
}//SetCookie(name,value)

function GetCookie(name)
{
	var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
	if(arr != null) return unescape(arr[2]); return null;
}//GetCookie(name)

function IfSelectFunction(CurrentCheckBox)
{	
	if (CurrentCheckBox.checked)
	{		
		AddToList(CurrentCheckBox.value);
		$(CheckBox_Name+CurrentCheckBox.value).checked=true;
	}
	else
	{
		RemoveToList(CurrentCheckBox.value);
		$(CheckBox_Name+CurrentCheckBox.value).checked=false;
	}
}//IfSelectFunction(CurrentCheckBox)

function AddToList(FunctionID)
{
	var FunctionString=GetCookie("SelectedID");

	if(FunctionString==""||FunctionString==null)
	{
		SetCookie("SelectedID",FunctionID);
		return;
	}
	
	SA=FunctionString.split("##");
	for(i=0;i<SA.length;i++)
	{
		if(FunctionID==SA[i])
		{
			return;
		}
	}
	
	
	FunctionString+="##"+FunctionID;	

	SetCookie("SelectedID",FunctionString);
}//AddToList(FunctionID)

function RemoveToList(FunctionID)
{	
	var FunctionString=GetCookie("SelectedID");
	var SA;
	var i;
	var ii=0;
	
	if(FunctionString==""||FunctionString==null)
	{
		SetCookie("SelectedID","");
		return;
	}
	
	
	SA=FunctionString.split("##");
	for(i=0;i<SA.length;i++)
	{
		if(FunctionID==SA[i])
		{
			SA[i]="";
		}
	}
	
	FunctionString="";
	
	for(i=0;i<SA.length;i++)
	{
		
		if(SA[i]!="")
		{	
			if(ii==0)
			{
				FunctionString=SA[i];	
			}
			else
			{
				FunctionString+="##"+SA[i];	
			}
			ii=ii+1;
		}
	}
	
	if (FunctionString=="##")
	{
		FunctionString="";
	}
	
	SetCookie("SelectedID",FunctionString);
}//RemoveToList(FunctionID)

function $(ID)
{
	return document.getElementById(ID);
}//$(ID)

function CopyData(Message)
{
	window.clipboardData.setData("Text",Message);
}//CopyData(Message)

function Add_Path_Template(PathString,ReplaceString)
{
	return PathString.replace("{uniworld}",ReplaceString);
}//Add_Path_Template(PathString,ReplaceString)

function Show_High_Res_Image(PictureID)
{
	var ImageName="";
	var NextButton="";	
	var TheID=0;
	var Checked="";
	var PopDiv02String="";
	var ID_S;
	
	CurrentPictureID=PictureID;
	
	ImageName=Add_Path_Template(Path_High_Image_String,PictureID);
	
	$("Pictures").innerHTML='<div id="PopDiv01" style="position:absolute; left:0px; top:0px; width:'+document.body.scrollWidth+'; height:100%; background-color:#CCCCCC;filter: alpha(opacity='+Photo_Background_Alpha+');-moz-opacity:'+(Photo_Background_Alpha/100)+';"></div>';
	
	TheID=BeginID+PictureID;
	try
	{
		if($(CheckBox_Name+PictureID).checked==true)
		{
			Checked=" checked";
		}
	}
	catch(ok)
	{
		
	}
	ID_S=Add_Path_Template(Album_ID_String,TheID);
	
	PopDiv02String+='<div style="z-index:109; background-color:#FFFFFF;padding:10px; border:1px solid #666666;">';
	
	PopDiv02String+='<div style="text-align:center;"><img src="'+ImageName+'" height="'+High_Image_Height+'" alt="'+ID_S+'"/></div>';
	
	PopDiv02String+='<div style="margin:10px 30px; text-align:left; font-size:16px; ">'+ID_S+'</div>';	
	
	PopDiv02String+='<div style="margin:10px 30px; text-align:center; font-size:16px; margin:0 auto;">';
	
	PopDiv02String+='<table border="0" align="center" cellpadding="0" cellspacing="0"><tr>';
	
	PopDiv02String+='<td width="80" align="center">';
	PopDiv02String+='<a href="javascript:PreviousPicture();">';
	PopDiv02String+='<img src="'+Path_Root+'images/other/Left.jpg" border="0"/>';
	PopDiv02String+='</a>';
	PopDiv02String+='</td>';
	
	PopDiv02String+='<td>';
	PopDiv02String+='<table border="0" align="left" cellpadding="0" cellspacing="0"><tr>';
	PopDiv02String+='<td width="60">';
	PopDiv02String+='<input type="checkbox" name="'+Another_CheckBox_Name+PictureID+'" id="'+Another_CheckBox_Name+PictureID+'" value="'+PictureID+'" onclick="IfSelectFunction(this);"'+Checked+'>';
	PopDiv02String+='</td>';
	PopDiv02String+='<td align="center">';
	PopDiv02String+=Album_CheckBoxString;	
	PopDiv02String+='</td>';
	PopDiv02String+='</tr></table>';
	PopDiv02String+='</td>';
	
	PopDiv02String+='<td width="150" align="center">';
	PopDiv02String+='<a href="javascript:NextPicture();"><img src="'+Path_Root+'images/other/Right.jpg" border="0"/></a>';	
	PopDiv02String+='</td>';
	
	PopDiv02String+='</tr></table>';
	PopDiv02String+='</div>';	
	
	PopDiv02String+='<div style="text-align:left;">';
	PopDiv02String+='<table border="0" align="center" cellpadding="0" cellspacing="0" width="600"><tr>';
	PopDiv02String+='<td align="left">';
	PopDiv02String+='<a href="'+Path_Root+'Default.asp?Action=Selected"><img src="'+Path_Root+'images/other/Selected.jpg" border="0"/></a>';
	PopDiv02String+='</td>';
	PopDiv02String+='<td align="right" valign="bottom">';
	PopDiv02String+='<a href="javascript:CloseSectionPicture();"><img src="'+Path_Root+'images/other/Close.jpg" border="0"/></a>';	
	PopDiv02String+='</td>';
	PopDiv02String+='</tr></table>';
	PopDiv02String+='</div>';
	
	PopDiv02String+='</div>';

	supersleight.init();
	$("PopDiv02").innerHTML=PopDiv02String;	
	
	document.getElementById("PopDiv02").style.top=(document.documentElement.scrollTop+30)+"px";	
	document.getElementById("PopDiv02").style.left=((document.body.scrollWidth/2)-315)+"px";
	document.getElementById("PopDiv01").style.height=document.documentElement.scrollHeight+"px";	
	
}//Show_High_Res_Image(PictureID)

function GetSelectedID(PreOrNext,ID)
{
	var FunctionString=GetCookie("SelectedID");	
	var SA=FunctionString.split("##");
	var I;
	var CP=0;
	var TotalP=SA.length-1;
	
	//alert(FunctionString);

	for (I=0;I<SA.length;I++)
	{
		if(parseInt(SA[I])==ID)
		{

			if(PreOrNext==0)
			{
				CP=I+1;
				if(TotalP<CP)
				{
					CP=0;	
				}					
			}
			else if(PreOrNext==1)
			{		
				CP=I-1;
				
				if(CP==-1)
				{
					CP=TotalP;	
				}					
			}	
			
		}
	}
	
	return SA[CP];
}

function NextPicture()
{
	if(window.location.href.toLowerCase().indexOf("selected")>0)
	{
		CurrentPictureID=GetSelectedID(0,CurrentPictureID);
	}
	else
	{
		CurrentPictureID+=1;
		if (TotalPictureCount<CurrentPictureID)
		{
			CurrentPictureID=1;
		}		
	}
	
	Show_High_Res_Image(CurrentPictureID);
}//NextPicture()

function PreviousPicture()
{
	if(window.location.href.toLowerCase().indexOf("selected")>0)
	{
		CurrentPictureID=GetSelectedID(1,CurrentPictureID);
	}
	else
	{
		CurrentPictureID=CurrentPictureID-1;
		if (CurrentPictureID==0)
		{
			CurrentPictureID=TotalPictureCount;
		}
	}
	Show_High_Res_Image(CurrentPictureID);
}//PreviousPicture()

function CloseSectionPicture()
{
	$("Pictures").innerHTML='';	
	$("PopDiv02").innerHTML='';
}//CloseSectionPicture()

window.onload=function()
{
	//alert(window.location.href.toLowerCase().indexOf("selected")>0);
}//window.onload=function()

function CheckContact()
{
	if(GetCookie("SelectedID")==""||GetCookie("SelectedID")==null||$("Email").value==""||$("Company").value==""||$("TheName").value=="")
	{
		alert(No_ID_String);
		return false;
	}
	return true;
}

function ClearAll()
{
	if(confirm(Clear_All_String))
	{
		SetCookie("SelectedID","");
		window.location=Path_Root+"Default.asp";
	}
}

function GetError()
{
	return true;
}

window.onerror=GetError;




function open_picture(picture_url)
{

	var Login="";
	var HTMLString="";
	var Height;
	var html_string_inner;
	//alert(window.screen.availHeight);
	if(document.documentElement.scrollHeight<window.screen.availHeight)
	{
		Height=window.screen.availHeight;
	}
	else
	{
		Height=document.documentElement.scrollHeight;		
	}
		
		html_string_inner='<div id="PopDiv01" style="position:absolute; left:0px; top:0px; width:100%; height:'+Height+'px; background-color:#000000;filter: alpha(opacity=60);-moz-opacity:0.9; z-index:99;"></div><div id="PopDiv02" style="position:absolute; left:0px; top:0px; width:100%; z-index:100;"><table width="500" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td height="'+(parseInt(document.documentElement.scrollTop)+50)+'">&nbsp;</td></tr><tr><td height="20" align="center" class="PopTableClose">';
		
		html_string_inner+='<table width="800" border="0" align="center" cellpadding="0" cellspacing="0" class="upload_images_table">';
		html_string_inner+='<tr>';
		html_string_inner+='<td align="center"><a href="javascript:Close_upload_picture();" class="close_button">Close</a></td>';
		html_string_inner+='</tr>';
		html_string_inner+='</table>';
		html_string_inner+='<div id="uploaded_images_result"><img src="'+picture_url+'">';
		html_string_inner+='</div>';

		
		
		html_string_inner+='</td></tr></table></div>';	
		

	document.getElementById("photo_album_div").innerHTML=html_string_inner;

	document.getElementById("PopDiv01").style.height=document.documentElement.scrollHeight+"px";	
	
}//Show_High_Res_Image(PictureID)



function Close_upload_picture()
{
	document.getElementById("photo_album_div").innerHTML='';		
}
