function setData()

	{

	var islocmulti=false

	for(ii=0;ii<datafields.length;ii++)

		{

		try

			{

			if(document.getElementById(datafields[ii]).type=="checkbox")

				{

				if(parseInt(data[ii])==document.getElementById(datafields[ii]).value)

					document.getElementById(datafields[ii]).checked=false

				else

					document.getElementById(datafields[ii]).checked=true



				if(parseInt(data[ii])==0)

					document.getElementById(datafields[ii]).checked=false

				else if(parseInt(data[ii])==1)

					document.getElementById(datafields[ii]).checked=true



				}



			else if(document.getElementById(datafields[ii]).type=="radio")

				{

				try

					{

					for(jj=0;jj<document.getElementsByName(datafields[ii]).length;jj++)

						{

						if(document.getElementsByName(datafields[ii])[jj].value==data[ii])

							{

							document.getElementsByName(datafields[ii])[jj].checked=true

							break;

							}

						}

					}

				catch(e)

					{

					if(document.getElementById(datafields[ii])[jj].value==data[ii])

						document.getElementById(datafields[ii]).checked=true

					}

				}



			else if(document.getElementById(datafields[ii]).type=="select-one")

				{

				setSelectedCombo(document.getElementById(datafields[ii]),data[ii])

				if(document.getElementById(datafields[ii]).name=="int_state_id")

					selectState(document.getElementById("int_country_id").options[document.getElementById("int_country_id").selectedIndex].value,document.getElementById(datafields[ii]).options[document.getElementById(datafields[ii]).selectedIndex].value)

				}

			else if(document.getElementById(datafields[ii]).type=="select-multiple")

				setSelectedComboMulti(document.getElementById(datafields[ii]),data[ii].split(","))

			else if(document.getElementById(datafields[ii]).type=="textarea")

				document.getElementById(datafields[ii]).value=parseEscapeString(data[ii])

			else

				document.getElementById(datafields[ii]).value=data[ii]

			}

		catch(e)

			{

			}



		}



	}



function parseEscapeString(str1)

	{

	tempstr=str1.split("<bn>");

	str1="";

	for(m=0;m<tempstr.length;m++)

		{

		if(m==0)

			str1=tempstr[m];

		else

			str1=str1+"\n"+tempstr[m];

		}

	tempstr=str1.split("<brn>");

	str1="";

	for(m=0;m<tempstr.length;m++)

		{

		if(m==0)

			str1=tempstr[m];

		else

			str1=str1+tempstr[m];

		}

	tempstr=str1.split("<qot>");

	str1="";

	for(m=0;m<tempstr.length;m++)

		{

		if(m==0)

			str1=tempstr[m];

		else

			str1=str1+"\""+tempstr[m];

		}

	return str1;

	}



function setSelectedCombo(cmb,str1)

	{

	for(kk=0;kk<cmb.options.length;kk++)

		{

		if(cmb.options[kk].value==str1)

			{

			cmb.selectedIndex=kk

			break;

			}

		}

	}





// ========================================***********************************



function trim_string(obj) {

     var ichar, icount;

     var strValue = obj.value

     ichar = strValue.length - 1;

     icount = -1;

     while (strValue.charAt(ichar)==' ' && ichar > icount)

         --ichar;

     if (ichar!=(strValue.length-1))

         strValue = strValue.slice(0,ichar+1);

     ichar = 0;

     icount = strValue.length - 1;

     while (strValue.charAt(ichar)==' ' && ichar < icount)

         ++ichar;

     if (ichar!=0)

         strValue = strValue.slice(ichar,strValue.length);

     return strValue;

 }



function trim_string_str(str1) {

     var ichar, icount;

     var strValue = str1

     ichar = strValue.length - 1;

     icount = -1;

     while (strValue.charAt(ichar)==' ' && ichar > icount)

         --ichar;

     if (ichar!=(strValue.length-1))

         strValue = strValue.slice(0,ichar+1);

     ichar = 0;

     icount = strValue.length - 1;

     while (strValue.charAt(ichar)==' ' && ichar < icount)

         ++ichar;

     if (ichar!=0)

         strValue = strValue.slice(ichar,strValue.length);

     return strValue;

 }





function allowOnlyCharKeys(e)

{

var key = parseInt(e.keyCode);

if((key < 65 || key > 90) && (key < 97 || key > 122 ))

	{

	e.keyCode=0;

	}

}



function allowOnlyNumKeys(e)

{

var key = parseInt(e.keyCode);

if((key < 48 || key > 57))

	{

	e.keyCode=0;

	}

}





function allowNumAndCharKeys(e)

{

var key = parseInt(e.keyCode);

if((key < 65 || key > 90) && (key < 97 || key > 122 ) && (key < 48 || key > 57) )

	{

	e.keyCode=0;

	}

}





function checkValidBirthDate(dd,mm,yy)

{

var monthDays="31,28,31,30,31,30,31,31,30,31,30,31".split(",")



var d=parseInt(dd.options[dd.selectedIndex].value)

var m=parseInt(mm.options[mm.selectedIndex].value)

var y=parseInt(yy.options[yy.selectedIndex].value)



if(y%4==0)

	monthDays[1]=29;



if(d>parseInt(monthDays[m-1]))

	{

	alert("The month you have selected only have " + monthDays[m-1] + " days.")

	dd.focus()

	return false;

	}



return true

}





var chars_type_1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";

var chars_type_2="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

var chars_type_3="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._@-'";

var chars_type_4="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789,./?!;:'+=-_)(*&%$@\n\r\t\"";

var chars_type_5="0123456789.";

var chars_type_6="0123456789.";



function checkValidText(obj,disptext,allowblank,charsallowed,emailfield,allowspace,minlength,maxlength,minvalue,maxvalue,checkvalue,checkstart)

	{

	// Function checkValidText Parameters 

	// Text Object , Alert Display Value, Allow Blank, Allowed Characters, Email Field, Allow Space, Min Length, Max Length	, MinValue , MaxValue, Checkvalue, Check Starting Letter

	var objvalue=trim_string(obj);

	obj.value=objvalue



	if(objvalue=="" && allowblank==true)  // Return True IF Allowed Blank

		return true;

	else if(objvalue=="")

		{

		alert("Please fill " + disptext + " field.");

		obj.focus()

		obj.select()

		return false

		}

	

	if(emailfield==true)

		{

		if(!checkValidEmail(obj))

			return false

		}



	if(allowspace==true)

		charsallowed+=" ";

	if(!checkCharsAllowed(objvalue,charsallowed,obj))

		return false



	if(objvalue.length<minlength && minlength>0)

		{

		alert("Please enter at least " + minlength + " characters in " + disptext + " field.")

		obj.select()

		obj.focus()

		return false

		}



	if(objvalue.length>maxlength && maxlength>0)

		{

		alert("Only " + maxlength + " characters are allowed in " + disptext + " field.")

		obj.select()

		obj.focus()

		return false

		}



	

	if(checkvalue==true)

		{

		if(parseFloat(objvalue)<minvalue || parseFloat(objvalue)>maxvalue)

			{

			alert("Please enter a numeric value between " + minvalue + " and " + maxvalue)

			obj.focus()

			obj.select()

			return false

			}

		}





	if(!checkStartLetter(obj,objvalue,checkstart,disptext))

		return false





	return true

	}



function checkStartLetter(obj,objvalue,checkstart,disptext)

	{

	if(checkstart!="")

		{

		var startarr=checkstart.split("|");

		var startchars=startarr[0]

		var startflag=startarr[1]



		for(i=0;i<startchars.length;i++)

			{

			if(startflag=="yes")

				{

				if(objvalue.charAt(0).toLowerCase()!=checkstart.charAt(i))

					{

					alert("Please enter the value staring with " + startchars + " in " + disptext + " field.")

					obj.select()

					obj.focus()

					return false

					}

				}

			else

				{

				if(objvalue.charAt(0).toLowerCase()==checkstart.charAt(i))

					{

					alert("Please do not enter the value staring with " + startchars + " in " + disptext + " field.")

					obj.select()

					obj.focus()

					return false

					}

				}

				

			}

		}



	return true;

	}





function checkCharsAllowed(objvalue,charsallowed,obj)

{

var str=objvalue

for(i=0;i<str.length;i++)

	{

	if(charsallowed.indexOf(str.charAt(i))==-1)

		{

		alert("You are only allowed to enter the following characters\n" + charsallowed)

		obj.focus()

		obj.select()

		return false

		}

	}

return true

}





function checkValidEmail(obj)

	{

obj.value=trim_string(obj)

    if(obj.value.length == 0)

	{

        alert("Email is required");

	obj.focus();

        return false;    

	}



    if(obj.value.indexOf("@",0) < 0)

			{

			alert('Please Enter Valid Email Address!');	

			obj.focus();	

			return false;

			}

	if(obj.value.indexOf(".",0) < 0)

		{

		alert('Please Enter Valid Email Address!');

		obj.focus();		

		return false;

		}

	if(obj.value.indexOf(" ",0) >= 0)

		{

		alert('Email Cannot Have Spaces');

		obj.focus();

		return false;

		}

	return true;

	}





function checkSelectedCombo(obj,disptext)

	{

	if(obj.selectedIndex<0)

		{

		alert("Please select " + disptext + " field.")

		obj.focus()

		return false

		}

	return true

	}



function selectTextField(obj)

	{

	obj.select()

	}





function checkValidImage(obj,allowblank)

    {

        if(obj.value=='')

        {

            alert("Please Select Image");

            obj.focus()

            return false;

        }

        var str=obj.value;

            var i;;

            var val=0;

            for(i=0;i<=str.length;i++)

            {

                if(str.charAt(i)=='.')

                    {

                    val++;    

                    }

            }

            var ext=str.substring( str.lastIndexOf('.')+1 , str.length);

                

            ext=ext.toLowerCase();  



            if(val=='1'&&(ext=="gif" || ext=="jpg" || ext=="jpeg"))

            {        

                return true;

            }

            else

                {

                    alert("Please select a Image Name which has single Dot(.)");

                    obj.focus()

                    return false;

                }

    }





function checkValidDateFormat(obj,reqformat,sepchar)

	{

	var str1=trim_string(obj)

	if(str1=="")

		{

		alert("Please fill the selected field. Format " + reqformat)

		obj.focus()

		return false;

		}



	temp=str1.split(sepchar)

	if(temp.length!=3)

		{

		alert("Invalid date format entered in the selected field. Format " + reqformat)

		obj.focus()

		return false;		

		}



	arr=reqformat.split('-')

	for(i=0;i<arr.length;i++)

		{

		if(arr[i]=="Y")

			yy=temp[i]

		else if(arr[i]=="m")

			mm=temp[i]

		else if(arr[i]=="d")

			dd1=temp[i]

		}





	if(isNaN(yy) || isNaN(mm) || isNaN(dd1))

		{

		alert("Invalid date entered in the selected field. Only digits are allowed and format is " + reqformat)

		obj.focus()

		return false;

		}



	if(yy.length>4 || mm.length>2 || dd1.length>2)

		{

		alert("Invalid date entered in the selected field. Please ensure to have max 4 digits in year, 2 digits in month and 2 digits in day.")

		obj.focus()

		return false;

		}				



	if(Math.ceil(yy)<1000 || Math.ceil(yy)>9999 || Math.ceil(mm)<1 || Math.ceil(mm)>12 || Math.ceil(dd1)<1 || Math.ceil(dd1)>31)

		{

		alert("Invalid date entered in the selected field. Please check month and day.")

		obj.focus()

		return false;

		}



	if(!checkValidDate(dd1,mm,yy))

		{

		alert("Invalid date entered in the selected field. Please check number of days in given month.")

		obj.focus()

		return false;	

		}

	

	return true

	}





function checkValidDate(dd1,mm,yy)

{

var monthDays="31,28,31,30,31,30,31,31,30,31,30,31".split(",")



var d=Math.ceil(dd1)

var m=Math.ceil(mm)

var y=Math.ceil(yy)



if(y%4==0)

	monthDays[1]=29;



if(d>parseInt(monthDays[m-1]))

	{

	return false;

	}



return true

}



// MM_MENU



function mmLoadMenus() {

  if (window.mm_menu_1101205126_0) return ;

     window.mm_menu_1101205126_0 = new Menu("root",180,20,"Verdana, Arial, Helvetica,sans-serif",10,"#000000","#CC0000","#ffffff","#ffffff","left","middle",5,0,1000,-5,7,true,true,true,0,true,true);

  mm_menu_1101205126_0.addMenuItem("Contemporary&nbsp;Art","location='http://www.indianartideas.com/index.php?pagename=artworks.php&utype=Artist&cat=Painting&col=style&val=Contemporary&entire=0'");

  mm_menu_1101205126_0.addMenuItem("Modern&nbsp;Art","location='http://www.indianartideas.com/index.php?pagename=artworks.php&utype=Artist&cat=Painting&col=style&val=Modern&entire=0'");

  mm_menu_1101205126_0.addMenuItem("Traditional&nbsp;Art","location='http://www.indianartideas.com/index.php?pagename=traditional.php'");

  mm_menu_1101205126_0.addMenuItem("Sketching:&nbsp;Magic&nbsp;Of&nbsp;Pencil","location='http://www.indianartideas.com/index.php?pagename=artworks.php&utype=Artist&cat=Painting&col=style&val=Sketching&entire=0'");

  /*mm_menu_1101205126_0.addMenuItem("Care&nbsp;&&nbsp;Conservation&nbsp;","location='careconservation.php'");

  mm_menu_1101205126_0.addMenuItem("Art&nbsp;Classes&nbsp;","location='artclasses.php'");*/

   mm_menu_1101205126_0.fontWeight="bold";

   mm_menu_1101205126_0.hideOnMouseOut=true;

   mm_menu_1101205126_0.bgColor='#555555';

   mm_menu_1101205126_0.menuBorder=1;

   mm_menu_1101205126_0.menuLiteBgColor='#FFFFFF';

   mm_menu_1101205126_0.menuBorderBgColor='#777777';



//mm_menu_1101205126_0.writeMenus();

      window.mm_menu_0823023258_0 = new Menu("root",180,20,"Verdana, Arial, Helvetica, sans-serif",10,"#000000","#CC0000","#FFFFFF","#FFFFFF","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);

  mm_menu_0823023258_0.addMenuItem("Landscape","location='http://www.indianartideas.com/Subject/landscape-art'");

  mm_menu_0823023258_0.addMenuItem("Figurative","location='http://www.indianartideas.com/Subject/Figurative-art'");

  mm_menu_0823023258_0.addMenuItem("Religion","location='http://www.indianartideas.com/Subject/Religion'");
  mm_menu_0823023258_0.addMenuItem("Still Life","location='http://www.indianartideas.com/Subject/Still-life-art'");
  mm_menu_0823023258_0.addMenuItem("Abstract","location='http://www.indianartideas.com/Subject/Abstract-art'");
  mm_menu_0823023258_0.addMenuItem("Surrealism","location='http://www.indianartideas.com/Subject/Surrealism'");
   mm_menu_0823023258_0.fontWeight="bold";

   mm_menu_0823023258_0.hideOnMouseOut=true;

   mm_menu_0823023258_0.bgColor='#555555';

   mm_menu_0823023258_0.menuBorder=1;

   mm_menu_0823023258_0.menuLiteBgColor='#FFFFFF';

   mm_menu_0823023258_0.menuBorderBgColor='#666666';

   

   window.mm_menu_0823023259_0 = new Menu("root",180,20,"Verdana, Arial, Helvetica, sans-serif",10,"#000000","#CC0000","#FFFFFF","#FFFFFF","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);

  mm_menu_0823023259_0.addMenuItem("Artist&nbsp;Corner","location='http://www.indianartideas.com/entire-art-gallery/from-the-artist-corner'");

  mm_menu_0823023259_0.addMenuItem("Collector&nbsp;Corner","location='http://www.indianartideas.com/entire-art-gallery/Art-collectors-corner/'");

  mm_menu_0823023259_0.fontWeight="bold";

   mm_menu_0823023259_0.hideOnMouseOut=true;

   mm_menu_0823023259_0.bgColor='#555555';

   mm_menu_0823023259_0.menuBorder=1;

   mm_menu_0823023259_0.menuLiteBgColor='#FFFFFF';

   mm_menu_0823023259_0.menuBorderBgColor='#666666';

	//mm_menu_0823023258_0.writeMenus();

	

	window.mm_menu_0823023257_0 = new Menu("root",180,20,"Verdana, Arial, Helvetica, sans-serif",10,"#000000","#CC0000","#FFFFFF","#FFFFFF","left","middle",3,0,1000,-5,7,true,true,true,0,true,true);

  mm_menu_0823023257_0.addMenuItem("Custom&nbsp;Portraits","location='http://www.indianartideas.com/art-personalized/custom-portraits'");

  mm_menu_0823023257_0.addMenuItem("Customized&nbsp;Paintings","location='http://www.indianartideas.com/art-personalized/custom-paintings'");



  mm_menu_0823023257_0.fontWeight="bold";

   mm_menu_0823023257_0.hideOnMouseOut=true;

   mm_menu_0823023257_0.bgColor='#555555';

   mm_menu_0823023257_0.menuBorder=1;

   mm_menu_0823023257_0.menuLiteBgColor='#FFFFFF';

   mm_menu_0823023257_0.menuBorderBgColor='#666666';

	mm_menu_0823023258_0.writeMenus();



}





function displayColorName(str1)

	{

	document.getElementById("colordisplay").innerHTML=str1

	}





function getColorName(str1,gurl,frmfld)

	{
	if(gurl==true)

		showArtworkByColor(str1)

	else

		{
		  if(document.getElementById(frmfld).value=="")
		  {
			document.getElementById(frmfld).value=str1
			document.getElementById("mycolorspace").style.display="none"
		  }
		  else
		  {
			var colornname=document.getElementById(frmfld).value;
			document.getElementById(frmfld).value=colornname+","+str1;
			document.getElementById("mycolorspace").style.display="none"
			
		  }

		}

	}




function showMyColorSpace(lft,tp)

	{

	document.getElementById("mycolorspace").style.left=lft

	document.getElementById("mycolorspace").style.top=tp

	document.getElementById("mycolorspace").style.display="block"

	}



// XML HTTP FUNCTIONS

function getXMLObject()

	{

	var navapp=navigator.appName.toLowerCase();

	if(navapp.indexOf('microsoft')==-1)

		var xhttp = new XMLHttpRequest();

	else

		var xhttp = new ActiveXObject("Microsoft.XMLHTTP");

	return xhttp;

	}



function getResponseText(urlpath)

	{

	var temphttp = getXMLObject();

	var tempresponse="";

	var myurl = urlpath;

	tempresponse=""

	temphttp.open("GET", myurl , false);

	temphttp.send(null);

	return temphttp.responseText;

	}



function showCustomPopupWindow(popname,elid,isdata,e)

	{

	if(window.event) e=window.event;

	var str1="<table width=90% align=center><tr><td align=right><font face=arial color=red size=4><u><b><a href=\"javascript:hideCustomPopup('" + popname + "')\">X</a></b></u></font></td></tr></table>";

	if(isdata==true)

		document.getElementById(popname).innerHTML=str1+elid

	else

		document.getElementById(popname).innerHTML=str1+document.getElementById(elid).innerHTML

	document.getElementById(popname).style.display="block"

	if(brname=="other")

		{

		xpos=e.clientX

		ypos=document.body.scrollTop+e.clientY

		}

	else

		{

		xpos=event.x

		ypos=document.body.scrollTop+event.y

		}





	document.getElementById(popname).style.top=ypos

	try

		{

		if((xpos+parseFloat(document.getElementById(popname).style.width))>screen.width)

			document.getElementById(popname).style.left=(xpos-parseFloat(document.getElementById(popname).style.width))

		else

			document.getElementById(popname).style.left=xpos

		}

	catch(e)

		{

		}

	}



function createCustomPopupWindow(popname,wid,ht,bgcol)

	{

	//document.write("<div id="+popname+" style='display:none;position:absolute;width:"+wid+";height:"+ht+";background-color:"+bgcol+";overflow:auto;border-style:solid;border-top-width:5;border-color:gray' onclick=\"this.style.display='none'\"></div>");

	document.write("<div id="+popname+" style='display:none;position:absolute;width:"+wid+";height:"+ht+";background-color:"+bgcol+";overflow:auto;border-style:solid;border-top-width:5;border-color:gray'></div>");

	}



function hideCustomPopup(popname)

	{

	document.getElementById(popname).style.display="none"

	}



var brname="other";

if(navigator.appName.toLowerCase().indexOf('microsoft')!=-1)

	brname="micro";





function checkValidUploadExtensions(obj,allowblank,exts,vexts)

	{

	obj.value=trim_string(obj)

	if(obj.value=="" && allowblank==true)

		return true

	var ext=obj.value.substring(obj.value.lastIndexOf(".")+1,obj.value.length).toLowerCase()

	var isfound=false;

	for(mm=0;mm<exts.length;mm++)

		{

		if(ext==exts[mm])

			{

			isfound=true

			break;

			}

		}



	if(isfound==true)

		{

		return true

		}

	else

		{

		alert("Please select a valid file with extensions " + vexts)

		obj.focus()

		return false

		}



	}